System brushes Resources

本文深入探讨了Win8Metro应用中MainPage.xaml文件中StaticResource ApplicationPageBackgroundThemeBrush的使用,解释了其在系统刷资源中的作用,并提供了详细的链接和参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在win8 metro应用空白项目模板里一定会对MainPage.xaml里的StaticResource ApplicationPageBackgroundThemeBrush 感到好奇,因为是在找不到ApplicationPageBackgroundThemeBrush这个静态资源在哪里定义的,如果用blend打开MainPage.xaml就恍然大悟了,原来它是System brushes Resources(系统刷资源),是在winRT里隐含定义的,在MSDN文档里也没看到到底这些System brushes Resources的清晰说明,详细介绍见这里:

http://metro.excastle.com/xaml-system-brushes

转载于:https://www.cnblogs.com/vsnext/archive/2012/12/11/2812610.html

C# using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp1 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public class StatusToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool isEnabled) { return isEnabled ? Brushes.Red : Brushes.Green; } return Brushes.Gray; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } public class MainViewModel : INotifyPropertyChanged { private bool _isAutoTradingEnabled; public bool IsAutoTradingEnabled { get => _isAutoTradingEnabled; set { _isAutoTradingEnabled = value; OnPropertyChanged(); OnPropertyChanged(nameof(ToggleButtonText)); } } public string ToggleButtonText => IsAutoTradingEnabled ? "关闭自动下单" : "开启自动下单"; public ICommand ToggleCommand => new RelayCommand(ToggleStatus); private void ToggleStatus(object obj) { IsAutoTradingEnabled = !IsAutoTradingEnabled; } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } public class RelayCommand : ICommand { private readonly Action<object> _execute; public RelayCommand(Action<object> execute) => _execute = execute; public bool CanExecute(object parameter) => true; public void Execute(object parameter) => _execute(parameter); public event EventHandler CanExecuteChanged; } } <Window x:Class="WpfApp1.MainWindow" 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:WpfApp1" mc:Ignorable="d" Title="自动下单控制" Height="200" Width="300">> <Window.Resources> <local:StatusToColorConverter x:Key="ColorConverter"/> </Window.Resources> <Window.DataContext> <local:MainViewModel/> </Window.DataContext> <Grid> <Button Content="{Binding ToggleButtonText}" Background="{Binding IsAutoTradingEnabled, Converter={StaticResource ColorConverter}}" Command="{Binding ToggleCommand}" Width="150" Height="40" FontSize="14" FontWeight="Bold" Margin="10"/> </Grid> </Window>
08-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值