小弟最近采用WPF,想简便的换肤,所以研究了一下!好了,废话不多说。先上图,上面ribbon是DEV控件 下面乱乱的全是WPF自带控件哦。
源码地址:http://download.youkuaiyun.com/detail/wangtao510/8127887
换肤步骤如下:
1、两个DLL ,DevExpress.DemoData.v13.1.Core.dll ,DevExpress.Xpf.DemoBase.v13.1.dll可以去dev安装路径下找;
2、DemoModuleControl.cs类 添加进系统,源码已上传 下面提供源码地址
3、首先建立一个窗体MainWindow 更改窗体信息
4;这里也要改
5、新建dev的ribbonWindow窗体DXRibbonWindow 然后再Grid下添加如下代码
<dxb:BarManager>
<dxb:BarManager.Items>
<dxr:RibbonGalleryBarItem Name="gTheme" >
<dxr:RibbonGalleryBarItem.Gallery>
<dxb:Gallery MinColCount="2" ColCount="10" RowCount="2" ItemCheckMode="Single" AllowHoverAnimation="True" AllowHoverImages="True" FilterCaption="Themes" IsItemCaptionVisible="False" ItemCaptionHorizontalAlignment="Center" HoverGlyphSize="96,96" ItemClick="Gallery_ItemClick">
<dxb:Gallery.Groups>
<dxb:GalleryItemGroup Caption="Standard">
<dxb:GalleryItem Caption="DXStyle" Glyph="Images/ThemeIcons/DXStyle.png"/>
<dxb:GalleryItem Caption="VS2010" Glyph="Images/ThemeIcons/VS2010.png"/>
<dxb:GalleryItem Caption="MetropolisDark" Glyph="Images/ThemeIcons/MetropolisDark.png"/>
<dxb:GalleryItem Caption="MetropolisLight" Glyph="Images/ThemeIcons/MetropolisLight.png"/>
<dxb:GalleryItem Caption="Seven" Glyph="Images/ThemeIcons/Seven_48x48.png"/>
<dxb:GalleryItem Caption="Light Gray" Glyph="Images/ThemeIcons/LightGray_48x48.png" />
<dxb:GalleryItem Caption="Deep Blue" Glyph="Images/ThemeIcons/DeepBlue_48x48.png"/>
</dxb:GalleryItemGroup>
<dxb:GalleryItemGroup Caption="Office2007">
<dxb:GalleryItem Caption="Office 2007 Black" Glyph="Images/ThemeIcons/Office2007Black_48x48.png"/>
<dxb:GalleryItem Caption="Office 2007 Blue" Glyph="Images/ThemeIcons/Office2007Blue_48x48.png"/>
<dxb:GalleryItem Caption="Office 2007 Silver" Glyph="Images/ThemeIcons/Office2007Silver_48x48.png"/>
</dxb:GalleryItemGroup>
<dxb:GalleryItemGroup Caption="Office2010">
<dxb:GalleryItem Caption="Office 2010 Black" Glyph="Images/ThemeIcons/Office2010Black_48x48.png"/>
<dxb:GalleryItem Caption="Office 2010 Blue" Glyph="Images/ThemeIcons/Office2010Blue_48x48.png"/>
<dxb:GalleryItem Caption="Office 2010 Silver" Glyph="Images/ThemeIcons/Office2010Silver_48x48.png"/>
</dxb:GalleryItemGroup>
<dxb:GalleryItemGroup Caption="Office2013">
<dxb:GalleryItem Caption="Office 2013" Glyph="Images/ThemeIcons/Office2013_48x48.png"/>
</dxb:GalleryItemGroup>
</dxb:Gallery.Groups>
</dxb:Gallery>
</dxr:RibbonGalleryBarItem.Gallery>
</dxr:RibbonGalleryBarItem>
</dxb:BarManager.Items>
</dxb:BarManager>
6、在ribbonPageGroup中添加的代码
7、在DXRibbonWindow的cs代码页面添加代码
void DXRibbonWindow1_Loaded(object sender, RoutedEventArgs e)
{
MainWindow a = new MainWindow();
OwnerDemoModule = a;
}
public RibbonDemoModule OwnerDemoModule { get; set; }
private void Gallery_ItemClick(object sender, GalleryItemEventArgs e)
{
string themeName = (string)e.Item.Caption;
themeName = themeName.Replace(" ", string.Empty);
OwnerDemoModule.Theme = Theme.FindTheme(themeName);
}
添加相应引用 生成就可以了!
源码网址:http://download.youkuaiyun.com/detail/wangtao510/8127887
如果没有积分就直接问我要把!