这是一个颠倒黑白的世界 TrueToFalseConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var v = (bool)value; return !v; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
为了使用简单,对常用的转换器定义了静态变量的引用:
常用转换器的静态引用 /// 使用实例:Converter={x:Static local:XConverter.TrueToFalseConverter} XConverter { public static BooleanToVisibilityConverter BooleanToVisibilityConverter { get { return Singleton<BooleanToVisibilityConverter>.GetInstance(); } } public static TrueToFalseConverter TrueToFalseConverter { get { return Singleton<TrueToFalseConverter>.GetInstance(); } } public static ThicknessToDoubleConverter ThicknessToDoubleConverter { get { return Singleton<ThicknessToDoubleConverter>.GetInstance(); } } public static BackgroundToForegroundConverter BackgroundToForegroundConverter { get { return Singleton<BackgroundToForegroundConverter>.GetInstance(); } } public static TreeViewMarginConverter TreeViewMarginConverter { get { return Singleton<TreeViewMarginConverter>.GetInstance(); } } public static PercentToAngleConverter PercentToAngleConverter { get { return Singleton<PercentToAngleConverter>.GetInstance(); } } }
然后使用时就不用在xaml中声明资源了,通过静态引用的方式使用,就是这样的:
EndAngle="{TemplateBinding Value, Converter={x:Static local:XConverter.PercentToAngleConverter}}"
2.6其他样式
Share.xaml:
SnapsToDevicePixels Text local:ControlAttachProperty.AllowsAnimation Foreground Margin
View CodeGlobal.xaml
TablControl 的样式,TablControl.xaml
CornerRadius FontSize BorderThickness KeyboardNavigation.DirectionalNavigation KeyboardNavigation.TabNavigation BorderThickness KeyboardNavigation.DirectionalNavigation KeyboardNavigation.TabNavigation
View Code
版权所有,文章来源:
个人能力有限,本文内容仅供学习、探讨,欢迎指正、交流。