zoukankan      html  css  js  c++  java
  • DevExpress 动态换肤

    我们都知道Devexpress内置了很多themes,那要怎么在使用时动态更改呢。

    下面是方法以:

    1、如果你们已经有主题了,那就在XAML中删除类似下下面的语句。

    dx:ThemeManager.ThemeName="LightGray" 

    2、确保你的XAML中Window是引用下面的

    <dx:DXWindow

        后台也一样:

    MainWindow : DXWindow

    3、下面就可以读取DevExpress中所有的主题:

    comboBoxEdit1.ItemsSource = Theme.Themes;

    4、更换应用主题:

    ThemeManager.ApplicationThemeName = Theme.Themes[comboBoxEdit1.SelectedIndex].Name;

    5、主程序更新布局:

    this.UpdateLayout(); //重新布局

    下面是Demo的完整代码:

    <dx:DXWindow
        x:Class="theme.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
        Title="DXApplication" Height="300" Width="400"
        SnapsToDevicePixels="True" UseLayoutRounding="True"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        >
        <dx:DXWindow.Resources>
    
        </dx:DXWindow.Resources>
    
        <Grid>
            <dxe:ComboBoxEdit HorizontalAlignment="Left" Margin="64,85,0,0" Name="comboBoxEdit1" VerticalAlignment="Top" Width="150" />
            <dxe:TextEdit EditValue="一个中国人" Height="40"  Width="200" Margin="64,120,0,0" />
        </Grid>
    
    </dx:DXWindow>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    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.Shapes;
    using DevExpress.Xpf.Core;
    
    
    namespace theme
    {
        public partial class MainWindow : DXWindow
        {
            public MainWindow()
            {
                InitializeComponent();           
    
                this.Loaded += delegate(object sender, RoutedEventArgs e)
                {
                    comboBoxEdit1.ItemsSource = Theme.Themes;
                    comboBoxEdit1.SelectedIndex = 0;
                };
    
                comboBoxEdit1.SelectedIndexChanged += delegate(object sender, RoutedEventArgs e)
                {
                    ThemeManager.ApplicationThemeName = Theme.Themes[comboBoxEdit1.SelectedIndex].Name;
                    this.UpdateLayout(); //重新布局
                  };
    
            }
         }
    }
  • 相关阅读:
    解决:Ubuntu12.04下使用ping命令返回ping:icmp open socket: Operation not permitted的解决
    【Magenta 项目初探】手把手教你用Tensorflow神经网络创造音乐
    python表达式操作符【学习python必知必会】
    关于提高python程序执行效率的思路和想法
    动手前的构思在编写程序中的重要性
    python 之禅
    HTTP 访问学习笔记 留坑
    软件工程与方法学——面向对象程序设计例子
    python 英文字串首字母改为大写
    Objective-C:方法缓存
  • 原文地址:https://www.cnblogs.com/amw2738/p/3742057.html
Copyright © 2011-2022 走看看