声明:本文内容适用于 Visual Studio 2015 RC 及 Windows 10 10069 SDK 环境下,若以后有任何变更,请以新的特性为准。十一、x:Bind 中使用强制转换这点是补充上一篇文章的,当时忘了写(-__-)b场景:需要绑定显示某个纯色背景的控件的背景 ...
声明:本文内容适用于 Visual Studio 2015 RC 及 Windows 10 10069 SDK 环境下,若以后有任何变更,请以新的特性为准。
十一、x:Bind 中使用强制转换
这点是补充上一篇文章的,当时忘了写(-__-)b
场景:需要绑定显示某个纯色背景的控件的背景颜色RGB值(感觉挺绕口的)。
因为在传统的绑定里,由于是动态的,而且我们也能确保 Background 的类型为 SolidColorBrush。
那么我们可以这么写绑定:
<Page x:Class="Build2015XamlDemo.XBindDemo2" ="http://schemas.microsoft.com/get='_blank'>winfx/2006/xaml/presentation" ="http://schemas.microsoft.com/winfx/2006/xaml" ="using:Build2015XamlDemo" ="http://schemas.microsoft.com/expression/blend/2008" ="http://schemas.open mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel> <Border x:Name="brd" Background="Red" Width="100" Height="100"/> <Border BorderBrush="Green" BorderThickness="2"> <StackPanel> <TextBlock Text="Binding 传统绑定" /> <TextBlock Text="{Binding ElementName=brd,Path=Background.Color.R}" /> <TextBlock Text="{Binding ElementName=brd,Path=Background.Color.G}" /> <TextBlock Text="{Binding ElementName=brd,Path=Background.Color.B}" /> </StackPanel> </Border> </StackPanel> </Grid></Page>
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:【Win10】开发中的新特性及原有的变更(二)
关键词:win
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。