关于wpf绑定和.net版本的影响 求各路大神帮助

Vida Wang Vida Wang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
xaml:
<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"));



app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>




app.config(3.5):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>



上述代码在.Net版本3.5时绑定正常,切换到4.0以上就不行了,窗体的绑定出现异常,因为使用了Border包装成了圆角,在4.0的时候就成了一个特别小的圆形,3.5时可以正常显示,求大神给个解释和解决方法!
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
Vida Wang
WPF/Silverlight 8,757 成员 12,031 内容