首先,感谢 @/*梦里花落知多少*/ 的无私分享,本文中的全部内容皆来自于 http://www.cnblogs.com/anding/p/5018363.html,加上我本身作的少量修改。html
有关控件样式,详情就看 /*梦里花落知多少*/ 的 WPF自定义控件与样式 系列文章app
我作的修改:框架
1.修复WindowBase由于设置AllowsTransparency为True致使XP系统上窗体显示异常的问题;ide
2.WindowBase默认样式添加自定义内容添加,添加位置为最小化按钮左边。函数
<core:WindowBase x:Class="MainShell.ShellView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="clr-namespace:WPFStyle;assembly=WPFStyle" xmlns:cm="clr-namespace:MainShell.Framework" xmlns:str="clr-namespace:Multilanguage;assembly=Multilanguage" xmlns:system="clr-namespace:System;assembly=mscorlib" Height="600" Width="900" Title="{str:StringResource ShellView_Title,DefaultValue=WPF-CM框架}"> <core:ControlAttachProperty.AttachContent> <ControlTemplate > <core:FButton Width="Auto" Style="{DynamicResource FButton_Transparency}" Content="{str:StringResource App_CurLang,DefaultValue=中文}" cm:Message.Attach="[Event Click]= [Action ChangeLang]"></core:FButton> </ControlTemplate> </core:ControlAttachProperty.AttachContent>
3.样式LoopProcessBar(圆环进度条)添加了默认数值显示;oop
4.自定义多选控件MultiComboBox的Text设置成只读post
新增的内容:url
1.解决datagrid退出编辑行才刷新的问题 用法:<DataGrid yy:DataGridHelper.RealTimeCommit="True">spa
2.解决PasswordBox绑定问题 用法:mywpf:PasswordBoxHelper.Attach="True" mywpf:PasswordBoxHelper.Password="{Binding Path=PassWord,Mode=TwoWay}"code
3.添加了基于TextBlock实现的显示当前日期时间的控件DateTimeLabel 用法:
<core:DateTimeLabel></core:DateTimeLabel>
<core:DateTimeLabel Format="yyyy-MM-dd dddd">
</core:DateTimeLabel><core:DateTimeLabel Format="HH:mm:ss"></core:DateTimeLabel>
4.等待窗口WaitingBox的WaitShow新增完成回调函数参数
5.MessageBoxX添加ShowSuccess和ShowFailure
可能记得不全,实际效果看DEMO吧。为了方法使用,我将全部内容都打包到一个项目中了,要使用的话,将项目添加到解决方法,添加项目引用,在App.xaml中添加如下内容:
<Application.Resources> <ResourceDictionary> <!--Begin MyWPFStyle--> <ResourceDictionary x:Name="Colors" Source="pack://application:,,,/WPFStyle;component/ControlStyle/Colors.xaml"></ResourceDictionary> <ResourceDictionary x:Name="Global" Source="pack://application:,,,/WPFStyle;component/ControlStyle/Global.xaml"></ResourceDictionary> <ResourceDictionary x:Name="Share" Source="pack://application:,,,/WPFStyle;component/ControlStyle/Share.xaml"></ResourceDictionary> <ResourceDictionary x:Name="FIconStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/FIconStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="FButtonStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/FButtonStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="TextBoxStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/TextBoxStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="CheckBoxStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/CheckBoxStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="RadioButonStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/RadioButonStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="CalendarStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/CalendarStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="DatePickerStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/DatePickerStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ScrollViewerStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ScrollViewerStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ListBoxStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ListBoxStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="DataGridStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/DataGridStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ListViewStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ListViewStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ComboBoxStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ComboBoxStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="MenuStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/MenuStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ContextMenuStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ContextMenuStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="TreeViewStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/TreeViewStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ProcessBarStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ProcessBarStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="BusyBoxStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/BusyBoxStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="ProgressRingStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/ProgressRingStyle.xaml"></ResourceDictionary> <ResourceDictionary x:Name="WindowBaseStyle" Source="pack://application:,,,/WPFStyle;component/ControlStyle/WindowBaseStyle.xaml"></ResourceDictionary> <!--End MyWPFStyle--> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
DEMO下载:
http://pan.baidu.com/s/1nuretr7