绑定资源
1.将元素绑定到一起
上一章 拉条改变字体大小就是了
2.绑定到非元素对象
<Window.Resources>
<FontFamily x:Key="CustomFont">Calibri</FontFamily>
</Window.Resources>
<Grid>
<StackPanel Name="StackPanel1">
<!--获取窗体字体样式-->
<TextBlock Height="auto" Text="{Binding Source={x:Static SystemFonts.IconFontFamily},Path=Source}"></TextBlock>
<!--获取自定义资源-->
<TextBlock Height="auto" Text="{Binding Source={StaticResource CustomFont},Path=Source}"></TextBlock>
<!--获取指定父级元素的属性-->
<TextBlock Height="auto" Text="{Binding Path=Name,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type StackPanel},AncestorLevel=1}}"></TextBlock>
</StackPanel>
</Grid>
转载于//www.cnblogs.com/wskxy/p/11355458.html
还没有评论,来说两句吧...