介绍一个通用的BoolToXXX转换类,这个类使用Binding对象的ConverterParameter和FallbackValue来实现布尔类型与任意值转换的功能。...ConverterParameter是数据绑定的时候UI传到ValueConverter的参数,比如要将一个字符串通过数据绑定转换成整数,可以通过ConverterParameter来指定按照十进制还是十六进制转换...parameter); } #endregion } 上面的Convert函数,通过判断绑定的布尔值,如果为真(True),则使用Binding对象的ConverterParameter...="{Binding ElementName=LayoutRoot, Path=BoolValue, Converter={StaticResource BoolToValueConverter}, ConverterParameter...="{Binding ElementName=LayoutRoot, Path=BoolValue, Converter={StaticResource BoolToValueConverter}, ConverterParameter
Visibility="{Binding DialogMode, Converter={helper:EnumExcludeConverter}, ConverterParameter...DownImage="{Binding DialogType, Converter={StaticResource AlterDialogWindow_ButtonConverter}, ConverterParameter...Binding YesButtonText}" Visibility="{Binding IsCountdown, Converter={StaticResource VisibilityConverter}, ConverterParameter...Binding YesButtonText}" Visibility="{Binding IsCountdown, Converter={StaticResource VisibilityConverter}, ConverterParameter...Binding}" Visibility="{Binding DialogMode, Converter={helper:EnumExcludeConverter}, ConverterParameter
数据绑定技术是非常普遍的, 比如: <TextBlock Text="{Binding Path=TweetText, Converter={StaticResource RemainingLength}, <em>ConverterParameter</em>...=140}" /> 与之对应的 Swiss 绑定为: Text TweetText, Converter=RemainingLength, ConverterParameter=140 Swiss 绑定语法看起来比...如果需要 ConverterParameter , 则在后面继续添加: , ConverterParameter=$ParameterValue$ $ParameterValue$ 允许的内容如下: 单引号或双引号表示字符串...ValueConverter , 而这个 ValueConverter 是 LengthValueConverter 的默认实例; Text Order.Amount, Converter=Trim, ConverterParameter...Order.Amount , 并应用 Trim ValueConverter , Converter 的参数是字符串 '£' ; Text Order.Amount, Converter=Trim, ConverterParameter
Grid Background="{Binding Foreground, ElementName=Row, Converter={StaticResource LightenConverter}, ConverterParameter...Grid Background="{Binding Foreground, ElementName=Row, Converter={StaticResource LightenConverter}, ConverterParameter...Grid Background="{Binding Foreground, ElementName=Row, Converter={StaticResource LightenConverter}, ConverterParameter
TextBlock Text="Score : 60" Foreground="{Binding Passed,Converter={StaticResource BoolToValueConverter},ConverterParameter...如果要支持复杂类型或者对应本地化等问题,可以将ConverterParameter和FallbackValue绑定到StaticResource : <SolidColorBrush...它的代码也十分简单(其实这才是ConverterParameter的正确用法): public object Convert(object value, Type targetType, object...在XAML中使用如下: <TextBlock Text="{Binding DoubleValue,Converter={StaticResource StringFormatConverter},<em>ConverterParameter</em>
Binding Progress,Source={StaticResource ProgressWrapper},Converter={StaticResource StringFormatConverter},ConverterParameter...Binding Progress,Source={StaticResource ProgressWrapper},Converter={StaticResource StringFormatConverter},ConverterParameter...Binding Progress,Source={StaticResource ProgressWrapper},Converter={StaticResource StringFormatConverter},ConverterParameter...Binding Progress,Source={StaticResource ProgressWrapper},Converter={StaticResource StringFormatConverter},ConverterParameter
UpdateSourceTrigger = UpdateSourceTrigger, Converter = Converter, ConverterParameter...= ConverterParameter, ConverterCulture = ConverterCulture, FallbackValue...new MultiBinding { Converter = HelperConverter.Current, ConverterParameter.../// /// [DefaultValue(null)] public object ConverterParameter
ZJClippingBorder CornerRadius="4" Visibility="{Binding IsStart, Converter={StaticResource anyTypeConverter}, ConverterParameter...ZJClippingBorder CornerRadius="4" Visibility="{Binding IsStart, Converter={StaticResource anyTypeConverter}, ConverterParameter
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter...SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter...DataGrid}}}" Visibility="{Binding HeadersVisibility, ConverterParameter...Grid.Column="1" Visibility="{Binding HeadersVisibility, ConverterParameter
HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding ConverterParameter
<Rectangle x:Name="rect2" Height="50" Width="{Binding Width, Converter={StaticResource DoubleAdd}, <em>ConverterParameter</em>...Rectangle x:Name="rect3" Height="50" Fill="Blue" Width="{Binding Width, Converter={StaticResource FEAdd}, <em>ConverterParameter</em>
Visibility="{Binding Message,Converter={x:Static base:XConverter.VisibilityWithOutStringConverter},ConverterParameter...Visibility="{Binding Message,Converter={x:Static base:XConverter.VisibilityWithOutStringConverter},ConverterParameter...Visibility="{Binding Message,Converter={x:Static base:XConverter.VisibilityWithOutStringConverter},ConverterParameter...Visibility="{Binding Message,Converter={x:Static base:XConverter.VisibilityWithOutStringConverter},ConverterParameter...Visibility="{Binding Message,Converter={x:Static base:XConverter.VisibilityWithOutStringConverter},ConverterParameter
Converter={StaticResource EntityCollectionValueConverter}, ConverterParameter
Converter={StaticResource GreaterOrEqualsConverter}, ConverterParameter
Reference DefaultPanContainer} ,Path=Content.TranslationX,Converter={StaticResource CalcValueConverter},ConverterParameter...Reference DefaultPanContainer} ,Path=Content.TranslationX,Converter={StaticResource CalcValueConverter},ConverterParameter
也是可以在扩展标记中定义,详见如下: Visibility="{Binding ElementName=CB, Path=IsChecked, Converter={StaticResource B2V},ConverterParameter
<Image Visibility="{Binding FriendInfo.Sex,Converter={StaticResource parameterToVisibility},<em>ConverterParameter</em>...<Image Visibility="{Binding FriendInfo.Sex,Converter={StaticResource parameterToVisibility},ConverterParameter
领取专属 10元无门槛券
手把手带您无忧上云