首先,感謝 @/*夢裏花落知多少*/ 的無私分享,本文中的全部內容皆來自於 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