8,757
社区成员
发帖
与我相关
我的任务
分享<Window x:Class="Anything.Form.wndTip"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Anything.Form"
xmlns:cls="clr-namespace:Anything.Class"
mc:Ignorable="d"
Title="wndTip"
Height="{Binding ElementName=txt,Path=ActualHeight}"
Width="{Binding ElementName=txt, Path=ActualWidth}"
AllowsTransparency="True"
Opacity="0"
Background="Transparent"
WindowStyle="None" >
<Border x:Name="BdrOut" Background="#FF0033a0" CornerRadius="5" BorderThickness="2"
Width="auto"
Height="auto" >
<Border x:Name="BdrIn" Background="#FFeeeeee" BorderThickness="1" CornerRadius="3"
Width="auto"
Height="auto">
<TextBlock x:Name="txt" FontSize="16" Padding="5" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:wndTip}},Path=Tip}" >
</TextBlock>
</Border>
</Border>
</Window>
public string Tip
{
get { return (string)GetValue(TipProperty); }
set { SetValue(TipProperty, value); }
}
public static readonly DependencyProperty TipProperty =
DependencyProperty.Register("Tip", typeof(string), typeof(wndTip), new PropertyMetadata("This is tip"));<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
[/quote]
把窗口的宽高,不要用binding。有一个sizetocontent属性。你绑定的目的是让它根据内容显示大小吧[/quote]恩,是的[/quote]我搞定了,谢谢大神的指点!
[/quote]
把窗口的宽高,不要用binding。有一个sizetocontent属性。你绑定的目的是让它根据内容显示大小吧[/quote]恩,是的
[/quote]
把窗口的宽高,不要用binding。有一个sizetocontent属性。你绑定的目的是让它根据内容显示大小吧

