• <menu id="w2i4a"></menu>
  • logo Devexpress WPF控件文檔中心
    文檔首頁>>Devexpress WPF控件文檔中心>>如何使用調(diào)色板資源

    如何使用調(diào)色板資源


    立即下載DevExpress WPF

    DevExpress主題允許在代碼中使用調(diào)色板顏色作為資源,您可以用DevExpress主題顏色繪制自定義控件來使應(yīng)用程序的樣式保持一致。

    您可以使用每種調(diào)色板顏色作為顏色(PaletteColorThemeKey)或畫筆(PaletteBrushThemeKey)。

    <ThemedWindow ...
    xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
    xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/core/themekeys">
    <Grid>
    <Button Background="{dxi:ThemeResource {dxt:PaletteBrushThemeKey ResourceKey=Button.Background}}"
    BorderBrush="{dxi:ThemeResource {dxt:PaletteBrushThemeKey ResourceKey=Border}}"
    BorderThickness="1" />
    </Grid>
    </ThemedWindow>

    示例

    下面的代碼示例演示了如何將VS2017Blue主題的邊界調(diào)色板資源綁定到自定義控件的BorderBrush屬性:

    CustomControls.cs:

    using System.Windows;
    using System.Windows.Controls;
    
    namespace WpfApp36 {
    public class CustomControl1 : Control {
    static CustomControl1() {
    DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1)));
    }
    
    public string Text {
    get { return (string)GetValue(TextProperty); }
    set { SetValue(TextProperty, value); }
    }
    public static readonly DependencyProperty TextProperty =
    DependencyProperty.Register("Text", typeof(string), typeof(CustomControl1), new PropertyMetadata(null));
    }
    }

    MainWindow.xaml:

    <Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:WpfApp36"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApp36.MainWindow">
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition/>
    </Grid.RowDefinitions>
    <local:CustomControl1 Grid.Row="0" Margin="5" Text="Custom control binding to a theme name"/>
    </Grid>
    </Window>
    CustomControl1_Resource.xaml:
    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/core/themekeys"
    xmlns:local="clr-namespace:WpfApp36">
    <Style TargetType="{x:Type local:CustomControl1}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type local:CustomControl1}">
    <Border BorderBrush="{DynamicResource {dxt:PaletteBrushThemeKey ResourceKey=Border, ThemeName=VS2017Blue}}" BorderThickness="3">
    <TextBlock Foreground="Black" HorizontalAlignment="Center" Text="{TemplateBinding Text}" VerticalAlignment="Center"/>
    </Border>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </ResourceDictionary>
    App.xaml:
    <Application x:Class="WpfApp36.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/WPFApp36;component/CustomControl1_Resources.xaml" />
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>
    </Application>

    添加XPF.Core 和VS2017Blue主題引用來運行這個項目。

    運用

    查看示例

    調(diào)色板顏色列表

    此部分包含調(diào)色板顏色名稱和值。

    您可以在以下文件中找到主題資源鍵:

    DevExpressControlsInstallationPath\Components\Sources\XPF\DevExpress.Xpf.Themes\Theme_Name\Core\Core\ Themes\Theme_Name\Palettes.xaml

    DevExpressControlsInstallationPath\Components\Sources\XPF\DevExpress.Xpf.Themes\Theme_Name\Core\Core\ Themes\Theme_Name\Palettes_Base.xaml

    Win11Dark:

    顏色

    Win11Light

    顏色

    Win10Dark

    顏色

    Win10Light

    顏色

    Office2019Black

    DevExpress VCL圖表控件

    Office2019Colorful

    顏色

    Office2019DarkGray

    顏色

    Office2019HighContrast

    顏色

    Office2019White

    顏色

    VS2019Blue

    顏色

    VS2019Dark

    顏色

    VS2019Light

    顏色

    VS2017Blue

    顏色

    VS2017Dark

    顏色

    VS2017Light

    顏色

    Office2016BlackSE

    顏色

    Office2016ColorfulSE

    顏色
    Office2016DarkGraySE
    顏色

    Office2016WhiteSE

     

    DevExpress VCL圖表控件
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();