├── .gitignore
├── README.txt
└── src
├── TestApplication
├── App.xaml
├── App.xaml.cs
├── Application.ico
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
└── TestApplication.csproj
├── WPFControls.Layout
├── BusyIndicator
│ ├── BusyIndicator.cs
│ └── BusyIndicator.xaml
├── DialogContainer
│ ├── DialogContainer.cs
│ └── DialogContainer.xaml
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Themes
│ └── Generic.xaml
├── TransitioningContentControl
│ ├── TransitioningContentControl.cs
│ └── TransitioningContentControl.xaml
├── VisualStates.cs
└── WPFControls.Layout.csproj
└── WPFControls.sln
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | obj
3 | bin
4 | _ReSharper.*
5 | _UpgradeReport.*
6 | *.csproj.user
7 | *.resharper.user
8 | *.resharper
9 | *.suo
10 | *.cache
11 | *~
12 | *.swp
13 | *.user
14 | TestResult.xml
15 | results
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | This is a collection of Custom WPF Controls.
2 |
3 | Some controls are direct ports from the Silverlight Toolkit (http://silverlight.codeplex.com/), modified to
4 | be used in WPF application.
5 |
6 | All credits goes to the Silverlight Toolkit Team.
--------------------------------------------------------------------------------
/src/TestApplication/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/TestApplication/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Windows;
6 |
7 | namespace TestApplication
8 | {
9 | ///
10 | /// Interaction logic for App.xaml
11 | ///
12 | public partial class App : Application
13 | {
14 | }
15 | }
--------------------------------------------------------------------------------
/src/TestApplication/Application.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenspettersson/WPF-Controls/02797e860fd3219b97a8f16afc061aabcee8c0e6/src/TestApplication/Application.ico
--------------------------------------------------------------------------------
/src/TestApplication/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------
/src/TestApplication/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Imaging;
11 | using System.Windows.Shapes;
12 |
13 | namespace TestApplication
14 | {
15 | ///
16 | /// Interaction logic for MainWindow.xaml
17 | ///
18 | public partial class MainWindow : Window
19 | {
20 | public MainWindow()
21 | {
22 | this.InitializeComponent();
23 |
24 | // Insert code required on object creation below this point.
25 | }
26 |
27 | private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
28 | {
29 | // TODO: Add event handler implementation here.
30 |
31 |
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/TestApplication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("TestApplication")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Microsoft")]
14 | [assembly: AssemblyProduct("TestApplication")]
15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("f5776e20-0553-4284-8854-66de4a358f92")]
26 |
27 | //In order to begin building localizable applications, set
28 | //CultureYouAreCodingWith in your .csproj file
29 | //inside a . For example, if you are using US english
30 | //in your source files, set the to en-US. Then uncomment
31 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
32 | //the line below to match the UICulture setting in the project file.
33 |
34 | //[assembly: NeutralResourcesLanguage("en-US" , UltimateResourceFallbackLocation.MainAssembly)]
35 |
36 | [assembly:ThemeInfo(
37 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
38 | //(used if a resource is not found in the page,
39 | // or application resource dictionaries)
40 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
41 | //(used if a resource is not found in the page,
42 | // app, or any theme specific resource dictionaries)
43 | )]
44 |
45 | // Version information for an assembly consists of the following four values:
46 | //
47 | // Major Version
48 | // Minor Version
49 | // Build Number
50 | // Revision
51 | //
52 | // You can specify all the values or you can default the Build and Revision Numbers
53 | // by using the '*' as shown below:
54 | // [assembly: AssemblyVersion("1.0.*")]
55 | [assembly: AssemblyVersion("1.0.0.0")]
56 | [assembly: AssemblyFileVersion("1.0.0.0")]
57 |
58 |
--------------------------------------------------------------------------------
/src/TestApplication/TestApplication.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 4.0.20525.0
7 | 2.0
8 | {f5776e20-0553-4284-8854-66de4a358f92}
9 | WinExe
10 | Properties
11 | TestApplication
12 | TestApplication
13 | TestApplication
14 | v4.0
15 | Client
16 | 512
17 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
18 | 4
19 | Application.ico
20 | true
21 |
22 |
23 | true
24 | full
25 | false
26 | bin\Debug\
27 | DEBUG;TRACE
28 | prompt
29 | 4
30 |
31 |
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 4.0
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | MSBuild:Compile
57 | Designer
58 |
59 |
60 | MSBuild:Compile
61 | Designer
62 |
63 |
64 | App.xaml
65 | Code
66 |
67 |
68 | MainWindow.xaml
69 | Code
70 |
71 |
72 |
73 |
74 | Code
75 |
76 |
77 |
78 | false
79 |
80 |
81 |
82 |
83 | {D07E13A1-B56E-4802-BAD4-96F988294716}
84 | WPFControls.Layout
85 |
86 |
87 |
88 |
95 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/BusyIndicator/BusyIndicator.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft Corporation.
2 | // This source is subject to the Microsoft Public License (Ms-PL).
3 | // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
4 | // All other rights reserved.
5 |
6 | using System;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Shapes;
10 | using System.Windows.Threading;
11 |
12 | namespace WPFControls.Layout.Controls
13 | {
14 | ///
15 | /// A control to provide a visual indicator when an application is busy.
16 | ///
17 | /// Preview
18 | [TemplateVisualState(Name = VisualStates.StateIdle, GroupName = VisualStates.GroupBusyStatus)]
19 | [TemplateVisualState(Name = VisualStates.StateBusy, GroupName = VisualStates.GroupBusyStatus)]
20 | [TemplateVisualState(Name = VisualStates.StateVisible, GroupName = VisualStates.GroupVisibility)]
21 | [TemplateVisualState(Name = VisualStates.StateHidden, GroupName = VisualStates.GroupVisibility)]
22 | [StyleTypedProperty(Property = "OverlayStyle", StyleTargetType = typeof(Rectangle))]
23 | [StyleTypedProperty(Property = "ProgressBarStyle", StyleTargetType = typeof(ProgressBar))]
24 | public class BusyIndicator : ContentControl
25 | {
26 | ///
27 | /// Gets or sets a value indicating whether the BusyContent is visible.
28 | ///
29 | protected bool IsContentVisible { get; set; }
30 |
31 | ///
32 | /// Timer used to delay the initial display and avoid flickering.
33 | ///
34 | private DispatcherTimer _displayAfterTimer;
35 |
36 | ///
37 | /// Instantiates a new instance of the BusyIndicator control.
38 | ///
39 | public BusyIndicator()
40 | {
41 | DefaultStyleKey = typeof(BusyIndicator);
42 | _displayAfterTimer = new DispatcherTimer();
43 | Loaded += delegate
44 | {
45 | _displayAfterTimer.Tick += new EventHandler(DisplayAfterTimerElapsed);
46 | };
47 | Unloaded += delegate
48 | {
49 | _displayAfterTimer.Tick -= new EventHandler(DisplayAfterTimerElapsed);
50 | _displayAfterTimer.Stop();
51 | };
52 | }
53 |
54 | ///
55 | /// Overrides the OnApplyTemplate method.
56 | ///
57 | public override void OnApplyTemplate()
58 | {
59 | base.OnApplyTemplate();
60 | ChangeVisualState(false);
61 | }
62 |
63 | ///
64 | /// Handler for the DisplayAfterTimer.
65 | ///
66 | /// Event sender.
67 | /// Event arguments.
68 | private void DisplayAfterTimerElapsed(object sender, EventArgs e)
69 | {
70 | _displayAfterTimer.Stop();
71 | IsContentVisible = true;
72 | ChangeVisualState(true);
73 | }
74 |
75 | ///
76 | /// Changes the control's visual state(s).
77 | ///
78 | /// True if state transitions should be used.
79 | protected virtual void ChangeVisualState(bool useTransitions)
80 | {
81 | VisualStateManager.GoToState(this, IsBusy ? VisualStates.StateBusy : VisualStates.StateIdle, useTransitions);
82 | VisualStateManager.GoToState(this, IsContentVisible ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions);
83 | }
84 |
85 | ///
86 | /// Gets or sets a value indicating whether the busy indicator should show.
87 | ///
88 | public bool IsBusy
89 | {
90 | get { return (bool)GetValue(IsBusyProperty); }
91 | set { SetValue(IsBusyProperty, value); }
92 | }
93 |
94 | ///
95 | /// Identifies the IsBusy dependency property.
96 | ///
97 | public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register(
98 | "IsBusy",
99 | typeof(bool),
100 | typeof(BusyIndicator),
101 | new PropertyMetadata(false, new PropertyChangedCallback(OnIsBusyChanged)));
102 |
103 | ///
104 | /// IsBusyProperty property changed handler.
105 | ///
106 | /// BusyIndicator that changed its IsBusy.
107 | /// Event arguments.
108 | private static void OnIsBusyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
109 | {
110 | ((BusyIndicator)d).OnIsBusyChanged(e);
111 | }
112 |
113 | ///
114 | /// IsBusyProperty property changed handler.
115 | ///
116 | /// Event arguments.
117 | protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e)
118 | {
119 | if (IsBusy)
120 | {
121 | if (DisplayAfter.Equals(TimeSpan.Zero))
122 | {
123 | // Go visible now
124 | IsContentVisible = true;
125 | }
126 | else
127 | {
128 | // Set a timer to go visible
129 | _displayAfterTimer.Interval = DisplayAfter;
130 | _displayAfterTimer.Start();
131 | }
132 | }
133 | else
134 | {
135 | // No longer visible
136 | _displayAfterTimer.Stop();
137 | IsContentVisible = false;
138 | }
139 | ChangeVisualState(true);
140 | }
141 |
142 | ///
143 | /// Gets or sets a value indicating the busy content to display to the user.
144 | ///
145 | public object BusyContent
146 | {
147 | get { return (object)GetValue(BusyContentProperty); }
148 | set { SetValue(BusyContentProperty, value); }
149 | }
150 |
151 | ///
152 | /// Identifies the BusyContent dependency property.
153 | ///
154 | public static readonly DependencyProperty BusyContentProperty = DependencyProperty.Register(
155 | "BusyContent",
156 | typeof(object),
157 | typeof(BusyIndicator),
158 | new PropertyMetadata(null));
159 |
160 | ///
161 | /// Gets or sets a value indicating the template to use for displaying the busy content to the user.
162 | ///
163 | public DataTemplate BusyContentTemplate
164 | {
165 | get { return (DataTemplate)GetValue(BusyContentTemplateProperty); }
166 | set { SetValue(BusyContentTemplateProperty, value); }
167 | }
168 |
169 | ///
170 | /// Identifies the BusyTemplate dependency property.
171 | ///
172 | public static readonly DependencyProperty BusyContentTemplateProperty = DependencyProperty.Register(
173 | "BusyContentTemplate",
174 | typeof(DataTemplate),
175 | typeof(BusyIndicator),
176 | new PropertyMetadata(null));
177 |
178 | ///
179 | /// Gets or sets a value indicating how long to delay before displaying the busy content.
180 | ///
181 | public TimeSpan DisplayAfter
182 | {
183 | get { return (TimeSpan)GetValue(DisplayAfterProperty); }
184 | set { SetValue(DisplayAfterProperty, value); }
185 | }
186 |
187 | ///
188 | /// Identifies the DisplayAfter dependency property.
189 | ///
190 | public static readonly DependencyProperty DisplayAfterProperty = DependencyProperty.Register(
191 | "DisplayAfter",
192 | typeof(TimeSpan),
193 | typeof(BusyIndicator),
194 | new PropertyMetadata(TimeSpan.FromSeconds(0.1)));
195 |
196 | ///
197 | /// Gets or sets a value indicating the style to use for the overlay.
198 | ///
199 | public Style OverlayStyle
200 | {
201 | get { return (Style)GetValue(OverlayStyleProperty); }
202 | set { SetValue(OverlayStyleProperty, value); }
203 | }
204 |
205 | ///
206 | /// Identifies the OverlayStyle dependency property.
207 | ///
208 | public static readonly DependencyProperty OverlayStyleProperty = DependencyProperty.Register(
209 | "OverlayStyle",
210 | typeof(Style),
211 | typeof(BusyIndicator),
212 | new PropertyMetadata(null));
213 |
214 | ///
215 | /// Gets or sets a value indicating the style to use for the progress bar.
216 | ///
217 | public Style ProgressBarStyle
218 | {
219 | get { return (Style)GetValue(ProgressBarStyleProperty); }
220 | set { SetValue(ProgressBarStyleProperty, value); }
221 | }
222 |
223 | ///
224 | /// Identifies the ProgressBarStyle dependency property.
225 | ///
226 | public static readonly DependencyProperty ProgressBarStyleProperty = DependencyProperty.Register(
227 | "ProgressBarStyle",
228 | typeof(Style),
229 | typeof(BusyIndicator),
230 | new PropertyMetadata(null));
231 | }
232 |
233 | }
--------------------------------------------------------------------------------
/src/WPFControls.Layout/BusyIndicator/BusyIndicator.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
19 |
20 |
21 |
22 |
23 |
31 |
32 |
33 |
35 |
37 |
39 |
41 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
55 |
56 |
57 | Collapsed
58 |
59 |
60 |
61 |
65 |
66 |
67 | Collapsed
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
79 |
80 |
81 | Visible
82 |
83 |
84 |
85 |
89 |
90 |
91 | Visible
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
105 |
106 |
107 | True
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
119 |
120 |
121 | False
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
134 |
136 |
137 |
138 |
140 |
143 |
144 |
146 |
148 |
150 |
152 |
154 |
155 |
156 |
158 |
159 |
161 |
163 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
175 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/DialogContainer/DialogContainer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Shapes;
8 |
9 | namespace WPFControls.Layout.Controls
10 | {
11 | [TemplateVisualState(Name = VisualStates.StateVisible, GroupName = VisualStates.GroupVisibility)]
12 | [TemplateVisualState(Name = VisualStates.StateHidden, GroupName = VisualStates.GroupVisibility)]
13 | [StyleTypedProperty(Property = "OverlayStyle", StyleTargetType = typeof(Rectangle))]
14 | public class DialogContainer : ContentControl
15 | {
16 | public DialogContainer()
17 | {
18 | DefaultStyleKey = typeof(DialogContainer);
19 |
20 | Loaded += new RoutedEventHandler(DialogContainer_Loaded);
21 | }
22 |
23 | void DialogContainer_Loaded(object sender, RoutedEventArgs e)
24 | {
25 | ChangeVisualState(true);
26 | }
27 |
28 | protected bool IsContentVisible { get; set; }
29 |
30 | protected virtual void ChangeVisualState(bool useTransitions)
31 | {
32 | VisualStateManager.GoToState(this, IsShowing ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions);
33 | VisualStateManager.GoToState(this, IsContentVisible ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions);
34 | }
35 |
36 | public bool IsShowing
37 | {
38 | get { return (bool)GetValue(IsShowingProperty); }
39 | set { SetValue(IsShowingProperty, value); }
40 | }
41 |
42 | public static readonly DependencyProperty IsShowingProperty = DependencyProperty.Register(
43 | "IsShowing",
44 | typeof(bool),
45 | typeof(DialogContainer),
46 | new PropertyMetadata(false, new PropertyChangedCallback(OnIsShowingChanged)));
47 |
48 | private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
49 | {
50 | ((DialogContainer)d).OnIsShowingChanged(e);
51 | }
52 |
53 | protected virtual void OnIsShowingChanged(DependencyPropertyChangedEventArgs e)
54 | {
55 | if (IsShowing)
56 | {
57 | // Go visible now
58 | IsContentVisible = true;
59 |
60 | }
61 | else
62 | {
63 | // No longer visible
64 | IsContentVisible = false;
65 | }
66 | ChangeVisualState(true);
67 | }
68 |
69 |
70 | public object DialogContent
71 | {
72 | get { return (object)GetValue(DialogContentProperty); }
73 | set { SetValue(DialogContentProperty, value); }
74 | }
75 |
76 | public static readonly DependencyProperty DialogContentProperty = DependencyProperty.Register(
77 | "DialogContent",
78 | typeof(object),
79 | typeof(DialogContainer),
80 | new PropertyMetadata(null));
81 |
82 | public DataTemplate DialogContentTemplate
83 | {
84 | get { return (DataTemplate)GetValue(DialogContentTemplateProperty); }
85 | set { SetValue(DialogContentTemplateProperty, value); }
86 | }
87 |
88 | public static readonly DependencyProperty DialogContentTemplateProperty = DependencyProperty.Register(
89 | "DialogContentTemplate",
90 | typeof(DataTemplate),
91 | typeof(DialogContainer),
92 | new PropertyMetadata(null));
93 |
94 | public Style OverlayStyle
95 | {
96 | get { return (Style)GetValue(OverlayStyleProperty); }
97 | set { SetValue(OverlayStyleProperty, value); }
98 | }
99 |
100 | public static readonly DependencyProperty OverlayStyleProperty = DependencyProperty.Register(
101 | "OverlayStyle",
102 | typeof(Style),
103 | typeof(DialogContainer),
104 | new PropertyMetadata(null));
105 |
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/DialogContainer/DialogContainer.xaml:
--------------------------------------------------------------------------------
1 |
5 |
14 |
15 |
16 |
17 |
19 |
21 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 | Collapsed
42 |
43 |
44 |
45 |
46 |
50 |
51 |
52 | Collapsed
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
65 |
66 |
67 | Visible
68 |
69 |
70 |
71 |
72 |
76 |
77 |
78 | Visible
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
91 |
93 |
94 |
95 |
96 |
98 |
101 |
102 |
104 |
106 |
108 |
110 |
112 |
113 |
114 |
116 |
117 |
119 |
121 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("WPFControls.Layout")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Microsoft")]
14 | [assembly: AssemblyProduct("WPFControls.Layout")]
15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WPFControls.Layout.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFControls.Layout.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WPFControls.Layout.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
12 |
13 |
322 |
323 |
324 |
337 |
338 |
339 |
340 |
341 |
349 |
350 |
351 |
353 |
355 |
357 |
359 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
373 |
374 |
375 | Collapsed
376 |
377 |
378 |
379 |
383 |
384 |
385 | Collapsed
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
397 |
398 |
399 | Visible
400 |
401 |
402 |
403 |
407 |
408 |
409 | Visible
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
423 |
424 |
425 | True
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
437 |
438 |
439 | False
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
452 |
454 |
455 |
456 |
458 |
461 |
462 |
464 |
466 |
468 |
470 |
472 |
473 |
474 |
476 |
477 |
479 |
481 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
493 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
517 |
518 |
519 |
520 |
522 |
524 |
526 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
542 |
543 |
544 | Collapsed
545 |
546 |
547 |
548 |
549 |
553 |
554 |
555 | Collapsed
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
568 |
569 |
570 | Visible
571 |
572 |
573 |
574 |
575 |
579 |
580 |
581 | Visible
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
595 |
596 |
597 | True
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
609 |
610 |
611 | False
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
624 |
626 |
627 |
628 |
629 |
631 |
634 |
635 |
637 |
639 |
641 |
643 |
645 |
646 |
647 |
649 |
650 |
652 |
654 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/TransitioningContentControl/TransitioningContentControl.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft Corporation.
2 | // This source is subject to the Microsoft Public License (Ms-PL).
3 | // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
4 | // All other rights reserved.
5 |
6 | using System;
7 | using System.Diagnostics.CodeAnalysis;
8 | using System.Globalization;
9 | using System.Linq;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Media.Animation;
13 |
14 | namespace WPFControls.Layout.Controls
15 | {
16 | public class TransitioningContentControl : ContentControl
17 | {
18 | #region Visual state names
19 | ///
20 | /// The name of the group that holds the presentation states.
21 | ///
22 | private const string PresentationGroup = "PresentationStates";
23 |
24 | ///
25 | /// The name of the state that represents a normal situation where no
26 | /// transition is currently being used.
27 | ///
28 | private const string NormalState = "Normal";
29 |
30 | ///
31 | /// The name of the state that represents the default transition.
32 | ///
33 | public const string DefaultTransitionState = "DefaultTransition";
34 | #endregion Visual state names
35 |
36 | #region Template part names
37 | ///
38 | /// The name of the control that will display the previous content.
39 | ///
40 | internal const string PreviousContentPresentationSitePartName = "PreviousContentPresentationSite";
41 |
42 | ///
43 | /// The name of the control that will display the current content.
44 | ///
45 | internal const string CurrentContentPresentationSitePartName = "CurrentContentPresentationSite";
46 |
47 | #endregion Template part names
48 |
49 | #region TemplateParts
50 | ///
51 | /// Gets or sets the current content presentation site.
52 | ///
53 | /// The current content presentation site.
54 | private ContentPresenter CurrentContentPresentationSite { get; set; }
55 |
56 | ///
57 | /// Gets or sets the previous content presentation site.
58 | ///
59 | /// The previous content presentation site.
60 | private ContentPresenter PreviousContentPresentationSite { get; set; }
61 | #endregion TemplateParts
62 |
63 | #region public bool IsTransitioning
64 |
65 | ///
66 | /// Indicates whether the control allows writing IsTransitioning.
67 | ///
68 | private bool _allowIsTransitioningWrite;
69 |
70 | ///
71 | /// Gets a value indicating whether this instance is currently performing
72 | /// a transition.
73 | ///
74 | public bool IsTransitioning
75 | {
76 | get { return (bool)GetValue(IsTransitioningProperty); }
77 | private set
78 | {
79 | _allowIsTransitioningWrite = true;
80 | SetValue(IsTransitioningProperty, value);
81 | _allowIsTransitioningWrite = false;
82 | }
83 | }
84 |
85 | ///
86 | /// Identifies the IsTransitioning dependency property.
87 | ///
88 | public static readonly DependencyProperty IsTransitioningProperty =
89 | DependencyProperty.Register(
90 | "IsTransitioning",
91 | typeof(bool),
92 | typeof(TransitioningContentControl),
93 | new PropertyMetadata(OnIsTransitioningPropertyChanged));
94 |
95 | ///
96 | /// IsTransitioningProperty property changed handler.
97 | ///
98 | /// TransitioningContentControl that changed its IsTransitioning.
99 | /// Event arguments.
100 | private static void OnIsTransitioningPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
101 | {
102 | TransitioningContentControl source = (TransitioningContentControl)d;
103 |
104 | if (!source._allowIsTransitioningWrite)
105 | {
106 | source.IsTransitioning = (bool)e.OldValue;
107 | throw new InvalidOperationException();
108 | }
109 | }
110 | #endregion public bool IsTransitioning
111 |
112 | ///
113 | /// The storyboard that is used to transition old and new content.
114 | ///
115 | private Storyboard _currentTransition;
116 |
117 | ///
118 | /// Gets or sets the storyboard that is used to transition old and new content.
119 | ///
120 | private Storyboard CurrentTransition
121 | {
122 | get { return _currentTransition; }
123 | set
124 | {
125 | // decouple event
126 | if (_currentTransition != null)
127 | {
128 | _currentTransition.Completed -= OnTransitionCompleted;
129 | }
130 |
131 | _currentTransition = value;
132 |
133 | if (_currentTransition != null)
134 | {
135 | _currentTransition.Completed += OnTransitionCompleted;
136 | }
137 | }
138 | }
139 |
140 | #region public string Transition
141 | ///
142 | /// Gets or sets the name of the transition to use. These correspond
143 | /// directly to the VisualStates inside the PresentationStates group.
144 | ///
145 | public string Transition
146 | {
147 | get { return GetValue(TransitionProperty) as string; }
148 | set { SetValue(TransitionProperty, value); }
149 | }
150 |
151 | ///
152 | /// Identifies the Transition dependency property.
153 | ///
154 | public static readonly DependencyProperty TransitionProperty =
155 | DependencyProperty.Register(
156 | "Transition",
157 | typeof(string),
158 | typeof(TransitioningContentControl),
159 | new PropertyMetadata(DefaultTransitionState, OnTransitionPropertyChanged));
160 |
161 | ///
162 | /// TransitionProperty property changed handler.
163 | ///
164 | /// TransitioningContentControl that changed its Transition.
165 | /// Event arguments.
166 | private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
167 | {
168 | TransitioningContentControl source = (TransitioningContentControl)d;
169 | string oldTransition = e.OldValue as string;
170 | string newTransition = e.NewValue as string;
171 |
172 | if (source.IsTransitioning)
173 | {
174 | source.AbortTransition();
175 | }
176 |
177 | // find new transition
178 | Storyboard newStoryboard = source.GetStoryboard(newTransition);
179 |
180 | // unable to find the transition.
181 | if (newStoryboard == null)
182 | {
183 | // could be during initialization of xaml that presentationgroups was not yet defined
184 | if (VisualStates.TryGetVisualStateGroup(source, PresentationGroup) == null)
185 | {
186 | // will delay check
187 | source.CurrentTransition = null;
188 | }
189 | else
190 | {
191 | // revert to old value
192 | source.SetValue(TransitionProperty, oldTransition);
193 |
194 | throw new ArgumentException(
195 | string.Format(CultureInfo.CurrentCulture, "Temporary removed exception message", newTransition));
196 | }
197 | }
198 | else
199 | {
200 | source.CurrentTransition = newStoryboard;
201 | }
202 | }
203 | #endregion public string Transition
204 |
205 | #region public bool RestartTransitionOnContentChange
206 | ///
207 | /// Gets or sets a value indicating whether the current transition
208 | /// will be aborted when setting new content during a transition.
209 | ///
210 | public bool RestartTransitionOnContentChange
211 | {
212 | get { return (bool)GetValue(RestartTransitionOnContentChangeProperty); }
213 | set { SetValue(RestartTransitionOnContentChangeProperty, value); }
214 | }
215 |
216 | ///
217 | /// Identifies the RestartTransitionOnContentChange dependency property.
218 | ///
219 | public static readonly DependencyProperty RestartTransitionOnContentChangeProperty =
220 | DependencyProperty.Register(
221 | "RestartTransitionOnContentChange",
222 | typeof(bool),
223 | typeof(TransitioningContentControl),
224 | new PropertyMetadata(false, OnRestartTransitionOnContentChangePropertyChanged));
225 |
226 | ///
227 | /// RestartTransitionOnContentChangeProperty property changed handler.
228 | ///
229 | /// TransitioningContentControl that changed its RestartTransitionOnContentChange.
230 | /// Event arguments.
231 | private static void OnRestartTransitionOnContentChangePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
232 | {
233 | ((TransitioningContentControl)d).OnRestartTransitionOnContentChangeChanged((bool)e.OldValue, (bool)e.NewValue);
234 | }
235 |
236 | ///
237 | /// Called when the RestartTransitionOnContentChangeProperty changes.
238 | ///
239 | /// The old value of RestartTransitionOnContentChange.
240 | /// The new value of RestartTransitionOnContentChange.
241 | protected virtual void OnRestartTransitionOnContentChangeChanged(bool oldValue, bool newValue)
242 | {
243 | }
244 | #endregion public bool RestartTransitionOnContentChange
245 |
246 | #region Events
247 | ///
248 | /// Occurs when the current transition has completed.
249 | ///
250 | public event RoutedEventHandler TransitionCompleted;
251 | #endregion Events
252 |
253 | ///
254 | /// Initializes a new instance of the class.
255 | ///
256 | public TransitioningContentControl()
257 | {
258 | DefaultStyleKey = typeof(TransitioningContentControl);
259 | }
260 |
261 | ///
262 | /// Builds the visual tree for the TransitioningContentControl control
263 | /// when a new template is applied.
264 | ///
265 | public override void OnApplyTemplate()
266 | {
267 | if (IsTransitioning)
268 | {
269 | AbortTransition();
270 | }
271 |
272 | base.OnApplyTemplate();
273 |
274 | PreviousContentPresentationSite = GetTemplateChild(PreviousContentPresentationSitePartName) as ContentPresenter;
275 | CurrentContentPresentationSite = GetTemplateChild(CurrentContentPresentationSitePartName) as ContentPresenter;
276 |
277 | if (CurrentContentPresentationSite != null)
278 | {
279 | CurrentContentPresentationSite.Content = Content;
280 | }
281 |
282 | // hookup currenttransition
283 | Storyboard transition = GetStoryboard(Transition);
284 | CurrentTransition = transition;
285 | if (transition == null)
286 | {
287 | string invalidTransition = Transition;
288 | // revert to default
289 | Transition = DefaultTransitionState;
290 |
291 | throw new ArgumentException(
292 | string.Format(CultureInfo.CurrentCulture, "Temporary removed exception message", invalidTransition));
293 | }
294 | VisualStateManager.GoToState(this, NormalState, false);
295 | }
296 |
297 | ///
298 | /// Called when the value of the property changes.
299 | ///
300 | /// The old value of the property.
301 | /// The new value of the property.
302 | protected override void OnContentChanged(object oldContent, object newContent)
303 | {
304 | base.OnContentChanged(oldContent, newContent);
305 |
306 | StartTransition(oldContent, newContent);
307 | }
308 |
309 | ///
310 | /// Starts the transition.
311 | ///
312 | /// The old content.
313 | /// The new content.
314 | [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "newContent", Justification = "Should be used in the future.")]
315 | private void StartTransition(object oldContent, object newContent)
316 | {
317 | // both presenters must be available, otherwise a transition is useless.
318 | if (CurrentContentPresentationSite != null && PreviousContentPresentationSite != null)
319 | {
320 | CurrentContentPresentationSite.Content = newContent;
321 |
322 | PreviousContentPresentationSite.Content = oldContent;
323 |
324 | // and start a new transition
325 | if (!IsTransitioning || RestartTransitionOnContentChange)
326 | {
327 | IsTransitioning = true;
328 | VisualStateManager.GoToState(this, NormalState, false);
329 | VisualStateManager.GoToState(this, Transition, true);
330 | }
331 | }
332 | }
333 |
334 | ///
335 | /// Handles the Completed event of the transition storyboard.
336 | ///
337 | /// The source of the event.
338 | /// The instance containing the event data.
339 | private void OnTransitionCompleted(object sender, EventArgs e)
340 | {
341 | AbortTransition();
342 |
343 | RoutedEventHandler handler = TransitionCompleted;
344 | if (handler != null)
345 | {
346 | handler(this, new RoutedEventArgs());
347 | }
348 | }
349 |
350 | ///
351 | /// Aborts the transition and releases the previous content.
352 | ///
353 | public void AbortTransition()
354 | {
355 | // go to normal state and release our hold on the old content.
356 | VisualStateManager.GoToState(this, NormalState, false);
357 | IsTransitioning = false;
358 | if (PreviousContentPresentationSite != null)
359 | {
360 | PreviousContentPresentationSite.Content = null;
361 | }
362 | }
363 |
364 | ///
365 | /// Attempts to find a storyboard that matches the newTransition name.
366 | ///
367 | /// The new transition.
368 | /// A storyboard or null, if no storyboard was found.
369 | private Storyboard GetStoryboard(string newTransition)
370 | {
371 | VisualStateGroup presentationGroup = VisualStates.TryGetVisualStateGroup(this, PresentationGroup);
372 | Storyboard newStoryboard = null;
373 | if (presentationGroup != null)
374 | {
375 | newStoryboard = presentationGroup.States
376 | .OfType()
377 | .Where(state => state.Name == newTransition)
378 | .Select(state => state.Storyboard)
379 | .FirstOrDefault();
380 | }
381 | return newStoryboard;
382 | }
383 | }
384 | }
--------------------------------------------------------------------------------
/src/WPFControls.Layout/TransitioningContentControl/TransitioningContentControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
12 |
321 |
--------------------------------------------------------------------------------
/src/WPFControls.Layout/VisualStates.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Linq;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 |
7 | namespace WPFControls.Layout
8 | {
9 | internal static class VisualStates
10 | {
11 | #region GroupCommon
12 | ///
13 | /// Common state group.
14 | ///
15 | public const string GroupCommon = "CommonStates";
16 |
17 | ///
18 | /// Normal state of the Common state group.
19 | ///
20 | public const string StateNormal = "Normal";
21 |
22 | ///
23 | /// Normal state of the Common state group.
24 | ///
25 | public const string StateReadOnly = "ReadOnly";
26 |
27 | ///
28 | /// MouseOver state of the Common state group.
29 | ///
30 | public const string StateMouseOver = "MouseOver";
31 |
32 | ///
33 | /// Pressed state of the Common state group.
34 | ///
35 | public const string StatePressed = "Pressed";
36 |
37 | ///
38 | /// Disabled state of the Common state group.
39 | ///
40 | public const string StateDisabled = "Disabled";
41 | #endregion GroupCommon
42 |
43 | #region GroupFocus
44 | ///
45 | /// Focus state group.
46 | ///
47 | public const string GroupFocus = "FocusStates";
48 |
49 | ///
50 | /// Unfocused state of the Focus state group.
51 | ///
52 | public const string StateUnfocused = "Unfocused";
53 |
54 | ///
55 | /// Focused state of the Focus state group.
56 | ///
57 | public const string StateFocused = "Focused";
58 | #endregion GroupFocus
59 |
60 | #region GroupSelection
61 | ///
62 | /// Selection state group.
63 | ///
64 | public const string GroupSelection = "SelectionStates";
65 |
66 | ///
67 | /// Selected state of the Selection state group.
68 | ///
69 | public const string StateSelected = "Selected";
70 |
71 | ///
72 | /// Unselected state of the Selection state group.
73 | ///
74 | public const string StateUnselected = "Unselected";
75 |
76 | ///
77 | /// Selected inactive state of the Selection state group.
78 | ///
79 | public const string StateSelectedInactive = "SelectedInactive";
80 | #endregion GroupSelection
81 |
82 | #region GroupExpansion
83 | ///
84 | /// Expansion state group.
85 | ///
86 | public const string GroupExpansion = "ExpansionStates";
87 |
88 | ///
89 | /// Expanded state of the Expansion state group.
90 | ///
91 | public const string StateExpanded = "Expanded";
92 |
93 | ///
94 | /// Collapsed state of the Expansion state group.
95 | ///
96 | public const string StateCollapsed = "Collapsed";
97 | #endregion GroupExpansion
98 |
99 | #region GroupPopup
100 | ///
101 | /// Popup state group.
102 | ///
103 | public const string GroupPopup = "PopupStates";
104 |
105 | ///
106 | /// Opened state of the Popup state group.
107 | ///
108 | public const string StatePopupOpened = "PopupOpened";
109 |
110 | ///
111 | /// Closed state of the Popup state group.
112 | ///
113 | public const string StatePopupClosed = "PopupClosed";
114 | #endregion
115 |
116 | #region GroupValidation
117 | ///
118 | /// ValidationStates state group.
119 | ///
120 | public const string GroupValidation = "ValidationStates";
121 |
122 | ///
123 | /// The valid state for the ValidationStates group.
124 | ///
125 | public const string StateValid = "Valid";
126 |
127 | ///
128 | /// Invalid, focused state for the ValidationStates group.
129 | ///
130 | public const string StateInvalidFocused = "InvalidFocused";
131 |
132 | ///
133 | /// Invalid, unfocused state for the ValidationStates group.
134 | ///
135 | public const string StateInvalidUnfocused = "InvalidUnfocused";
136 | #endregion
137 |
138 | #region GroupExpandDirection
139 | ///
140 | /// ExpandDirection state group.
141 | ///
142 | public const string GroupExpandDirection = "ExpandDirectionStates";
143 |
144 | ///
145 | /// Down expand direction state of ExpandDirection state group.
146 | ///
147 | public const string StateExpandDown = "ExpandDown";
148 |
149 | ///
150 | /// Up expand direction state of ExpandDirection state group.
151 | ///
152 | public const string StateExpandUp = "ExpandUp";
153 |
154 | ///
155 | /// Left expand direction state of ExpandDirection state group.
156 | ///
157 | public const string StateExpandLeft = "ExpandLeft";
158 |
159 | ///
160 | /// Right expand direction state of ExpandDirection state group.
161 | ///
162 | public const string StateExpandRight = "ExpandRight";
163 | #endregion
164 |
165 | #region GroupHasItems
166 | ///
167 | /// HasItems state group.
168 | ///
169 | public const string GroupHasItems = "HasItemsStates";
170 |
171 | ///
172 | /// HasItems state of the HasItems state group.
173 | ///
174 | public const string StateHasItems = "HasItems";
175 |
176 | ///
177 | /// NoItems state of the HasItems state group.
178 | ///
179 | public const string StateNoItems = "NoItems";
180 | #endregion GroupHasItems
181 |
182 | #region GroupIncrease
183 | ///
184 | /// Increment state group.
185 | ///
186 | public const string GroupIncrease = "IncreaseStates";
187 |
188 | ///
189 | /// State enabled for increment group.
190 | ///
191 | public const string StateIncreaseEnabled = "IncreaseEnabled";
192 |
193 | ///
194 | /// State disabled for increment group.
195 | ///
196 | public const string StateIncreaseDisabled = "IncreaseDisabled";
197 | #endregion GroupIncrease
198 |
199 | #region GroupDecrease
200 | ///
201 | /// Decrement state group.
202 | ///
203 | public const string GroupDecrease = "DecreaseStates";
204 |
205 | ///
206 | /// State enabled for decrement group.
207 | ///
208 | public const string StateDecreaseEnabled = "DecreaseEnabled";
209 |
210 | ///
211 | /// State disabled for decrement group.
212 | ///
213 | public const string StateDecreaseDisabled = "DecreaseDisabled";
214 | #endregion GroupDecrease
215 |
216 | #region GroupIteractionMode
217 | ///
218 | /// InteractionMode state group.
219 | ///
220 | public const string GroupInteractionMode = "InteractionModeStates";
221 |
222 | ///
223 | /// Edit of the DisplayMode state group.
224 | ///
225 | public const string StateEdit = "Edit";
226 |
227 | ///
228 | /// Display of the DisplayMode state group.
229 | ///
230 | public const string StateDisplay = "Display";
231 | #endregion GroupIteractionMode
232 |
233 | #region GroupLocked
234 | ///
235 | /// DisplayMode state group.
236 | ///
237 | public const string GroupLocked = "LockedStates";
238 |
239 | ///
240 | /// Edit of the DisplayMode state group.
241 | ///
242 | public const string StateLocked = "Locked";
243 |
244 | ///
245 | /// Display of the DisplayMode state group.
246 | ///
247 | public const string StateUnlocked = "Unlocked";
248 | #endregion GroupLocked
249 |
250 | #region GroupActive
251 | ///
252 | /// Active state.
253 | ///
254 | public const string StateActive = "Active";
255 |
256 | ///
257 | /// Inactive state.
258 | ///
259 | public const string StateInactive = "Inactive";
260 |
261 | ///
262 | /// Active state group.
263 | ///
264 | public const string GroupActive = "ActiveStates";
265 | #endregion GroupActive
266 |
267 | #region GroupWatermark
268 | ///
269 | /// Non-watermarked state.
270 | ///
271 | public const string StateUnwatermarked = "Unwatermarked";
272 |
273 | ///
274 | /// Watermarked state.
275 | ///
276 | public const string StateWatermarked = "Watermarked";
277 |
278 | ///
279 | /// Watermark state group.
280 | ///
281 | public const string GroupWatermark = "WatermarkStates";
282 | #endregion GroupWatermark
283 |
284 | #region GroupCalendarButtonFocus
285 | ///
286 | /// Unfocused state for Calendar Buttons.
287 | ///
288 | public const string StateCalendarButtonUnfocused = "CalendarButtonUnfocused";
289 |
290 | ///
291 | /// Focused state for Calendar Buttons.
292 | ///
293 | public const string StateCalendarButtonFocused = "CalendarButtonFocused";
294 |
295 | ///
296 | /// CalendarButtons Focus state group.
297 | ///
298 | public const string GroupCalendarButtonFocus = "CalendarButtonFocusStates";
299 | #endregion GroupCalendarButtonFocus
300 |
301 | #region GroupBusyStatus
302 | ///
303 | /// Busy state for BusyIndicator.
304 | ///
305 | public const string StateBusy = "Busy";
306 |
307 | ///
308 | /// Idle state for BusyIndicator.
309 | ///
310 | public const string StateIdle = "Idle";
311 |
312 | ///
313 | /// Busyness group name.
314 | ///
315 | public const string GroupBusyStatus = "BusyStatusStates";
316 | #endregion
317 |
318 | #region GroupVisibility
319 | ///
320 | /// Visible state name for BusyIndicator.
321 | ///
322 | public const string StateVisible = "Visible";
323 |
324 | ///
325 | /// Hidden state name for BusyIndicator.
326 | ///
327 | public const string StateHidden = "Hidden";
328 |
329 | ///
330 | /// BusyDisplay group.
331 | ///
332 | public const string GroupVisibility = "VisibilityStates";
333 | #endregion
334 |
335 | ///
336 | /// Use VisualStateManager to change the visual state of the control.
337 | ///
338 | ///
339 | /// Control whose visual state is being changed.
340 | ///
341 | ///
342 | /// A value indicating whether to use transitions when updating the
343 | /// visual state, or to snap directly to the new visual state.
344 | ///
345 | ///
346 | /// Ordered list of state names and fallback states to transition into.
347 | /// Only the first state to be found will be used.
348 | ///
349 | public static void GoToState(Control control, bool useTransitions, params string[] stateNames)
350 | {
351 | Debug.Assert(control != null, "control should not be null!");
352 | Debug.Assert(stateNames != null, "stateNames should not be null!");
353 | Debug.Assert(stateNames.Length > 0, "stateNames should not be empty!");
354 |
355 | foreach (string name in stateNames)
356 | {
357 | if (VisualStateManager.GoToState(control, name, useTransitions))
358 | {
359 | break;
360 | }
361 | }
362 | }
363 |
364 | ///
365 | /// Gets the implementation root of the Control.
366 | ///
367 | /// The DependencyObject.
368 | ///
369 | /// Implements Silverlight's corresponding internal property on Control.
370 | ///
371 | /// Returns the implementation root or null.
372 | public static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject)
373 | {
374 | Debug.Assert(dependencyObject != null, "DependencyObject should not be null.");
375 | return (1 == VisualTreeHelper.GetChildrenCount(dependencyObject)) ?
376 | VisualTreeHelper.GetChild(dependencyObject, 0) as FrameworkElement :
377 | null;
378 | }
379 |
380 | ///
381 | /// This method tries to get the named VisualStateGroup for the
382 | /// dependency object. The provided object's ImplementationRoot will be
383 | /// looked up in this call.
384 | ///
385 | /// The dependency object.
386 | /// The visual state group's name.
387 | /// Returns null or the VisualStateGroup object.
388 | public static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName)
389 | {
390 | FrameworkElement root = GetImplementationRoot(dependencyObject);
391 | if (root == null)
392 | {
393 | return null;
394 | }
395 |
396 | return VisualStateManager.GetVisualStateGroups(root)
397 | .OfType()
398 | .Where(group => string.CompareOrdinal(groupName, group.Name) == 0)
399 | .FirstOrDefault();
400 | }
401 | }
402 | }
--------------------------------------------------------------------------------
/src/WPFControls.Layout/WPFControls.Layout.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {D07E13A1-B56E-4802-BAD4-96F988294716}
9 | library
10 | Properties
11 | WPFControls.Layout
12 | WPFControls.Layout
13 | v4.0
14 |
15 |
16 | 512
17 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
18 | 4
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | 4.0
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | MSBuild:Compile
55 | Designer
56 |
57 |
58 | Designer
59 | MSBuild:Compile
60 |
61 |
62 | MSBuild:Compile
63 | Designer
64 |
65 |
66 | MSBuild:Compile
67 | Designer
68 |
69 |
70 |
71 |
72 |
73 |
74 | Code
75 |
76 |
77 | True
78 | True
79 | Resources.resx
80 |
81 |
82 | True
83 | Settings.settings
84 | True
85 |
86 |
87 |
88 |
89 | ResXFileCodeGenerator
90 | Resources.Designer.cs
91 |
92 |
93 | SettingsSingleFileGenerator
94 | Settings.Designer.cs
95 |
96 |
97 |
98 |
99 |
106 |
--------------------------------------------------------------------------------
/src/WPFControls.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFControls.Layout", "WPFControls.Layout\WPFControls.Layout.csproj", "{D07E13A1-B56E-4802-BAD4-96F988294716}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {D07E13A1-B56E-4802-BAD4-96F988294716}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {D07E13A1-B56E-4802-BAD4-96F988294716}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {D07E13A1-B56E-4802-BAD4-96F988294716}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {D07E13A1-B56E-4802-BAD4-96F988294716}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------