关于wpf绑定和.net版本的影响 求各路大神帮助
xaml:
后台关联的依赖项属性:
app.config:
app.config(3.5):
上述代码在.Net版本3.5时绑定正常,切换到4.0以上就不行了,窗体的绑定出现异常,因为使用了Border包装成了圆角,在4.0的时候就成了一个特别小的圆形,3.5时可以正常显示,求大神给个解释和解决方法!
<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时可以正常显示,求大神给个解释和解决方法!
...全文
相关推荐
WPF渲染和绑定性能比较
在本文中,我们将深入探讨WPF(Windows Presentation Foundation)中的渲染和绑定性能比较,主要关注在C# .NET环境中如何优化UI更新。
WPF的数据绑定详细介绍
WPF提供了四种不同的数据绑定模式,根据数据流的方向来决定何时以及如何更新源和目标:1. **OneWay绑定**:源属性的改变会自动更新目标属性,但目标属性的更改不会影响源。
WPF数据绑定例子
**WPF数据绑定详解**WPF(Windows Presentation Foundation)是微软.NET Framework的一部分,它提供了丰富的用户界面(UI)设计和开发能力。
WPF的数据绑定
在WPF中,绑定源可以是多种类型的对象或数据结构: - **CLR对象**:可以绑定到.NET Framework类中的公共属性、子属性或索引器。
wpf仿iphone桌面翻页效果
**数据绑定**:WPF的数据绑定机制允许我们连接视图和视图模型,使得视图的变化能反映在视图模型上,反之亦然。这在处理页面索引和翻页状态时非常有用。5.


