diff --git a/WpfTraining/02 Data Bindings/01 Using Dependency Properties/01 Using Dependency Properties in Resources.xaml b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/01 Using Dependency Properties in Resources.xaml
new file mode 100644
index 00000000..50d88a27
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/01 Using Dependency Properties in Resources.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/01 Using Dependency Properties/02 Using Dependency Properties and Data Binding.xaml b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/02 Using Dependency Properties and Data Binding.xaml
new file mode 100644
index 00000000..8ea37275
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/02 Using Dependency Properties and Data Binding.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Authenticate with User
+ and Password
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/01 Using Dependency Properties/03 Using Dependency Properties and Styles.xaml b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/03 Using Dependency Properties and Styles.xaml
new file mode 100644
index 00000000..df2f7cff
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/03 Using Dependency Properties and Styles.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Authenticate with User
+ and Password
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/01 Using Dependency Properties/04 Using Dependency Properties and Animations.xaml b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/04 Using Dependency Properties and Animations.xaml
new file mode 100644
index 00000000..d5b1b2e5
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/04 Using Dependency Properties and Animations.xaml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/01 Using Dependency Properties/05 Using Dependency Properties using RelativeSource.xaml b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/05 Using Dependency Properties using RelativeSource.xaml
new file mode 100644
index 00000000..97886973
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/01 Using Dependency Properties/05 Using Dependency Properties using RelativeSource.xaml
@@ -0,0 +1,16 @@
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.config b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.config
new file mode 100644
index 00000000..c5e1daef
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.config
@@ -0,0 +1,3 @@
+
+
+
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml
new file mode 100644
index 00000000..2f58701a
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml.cs
new file mode 100644
index 00000000..80888be1
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/App.xaml.cs
@@ -0,0 +1,8 @@
+using System.Windows;
+
+namespace FreeSpaceWatcher
+{
+ public partial class App : Application
+ {
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceInfo.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceInfo.cs
new file mode 100644
index 00000000..b9143dc4
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceInfo.cs
@@ -0,0 +1,54 @@
+using System;
+using System.IO;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Threading;
+
+namespace Samples
+{
+ public class FreeSpaceInfo : DependencyObject
+ {
+ private DriveInfo currentDriveInfo = null;
+
+ public FreeSpaceInfo()
+ {
+ }
+
+ #region "Drive" dependency property
+ public static readonly DependencyProperty DriveProperty =
+ DependencyProperty.Register("Drive", typeof(string), typeof(FreeSpaceInfo),
+ new PropertyMetadata( new PropertyChangedCallback(OnDriveChanged)));
+ public string Drive
+ {
+ get { return (string)GetValue(DriveProperty); }
+ set { SetValue(DriveProperty, value); }
+ }
+ public static void OnDriveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ FreeSpaceInfo o = (FreeSpaceInfo)d;
+ // check if the drive property is empty
+ if (((string)e.NewValue).Length > 0)
+ {
+ // get data about the drive
+ o.currentDriveInfo = new DriveInfo((string)e.NewValue);
+ // set dependency property
+ d.SetValue(FreeSpaceRatioProperty,
+ Convert.ToDouble(o.currentDriveInfo.TotalFreeSpace) / o.currentDriveInfo.TotalSize);
+ }
+ else
+ // no drive has been selected -> set free space ratio to 0
+ d.SetValue(FreeSpaceRatioProperty, 0.0);
+ }
+ #endregion
+
+ #region "FreeSpaceRatio" dependency property
+ public double FreeSpaceRatio
+ {
+ // this property is read only -> no set is implemented
+ get { return (double)GetValue(FreeSpaceRatioProperty); }
+ }
+ public static readonly DependencyProperty FreeSpaceRatioProperty =
+ DependencyProperty.Register("FreeSpaceRatio", typeof(double), typeof(FreeSpaceInfo));
+ #endregion
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.csproj b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.csproj
new file mode 100644
index 00000000..c7bb2676
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.csproj
@@ -0,0 +1,141 @@
+
+
+
+ Debug
+ AnyCPU
+ {AC57A4BB-BCF4-49CC-832C-2C57F2F86322}
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ FreeSpaceWatcher
+ FreeSpaceWatcher
+ 4
+ winexe
+ 3.0
+ false
+ SAK
+ SAK
+ SAK
+ SAK
+ v4.5
+
+
+ 3.5
+
+
+
+
+ Publish\
+ true
+ Web
+ true
+ Foreground
+ 7
+ Days
+ false
+ false
+ false
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+ true
+ full
+ false
+ .\bin\Debug\
+ DEBUG;TRACE
+ AllRules.ruleset
+ false
+
+
+ false
+ true
+ .\bin\Release\
+ TRACE
+ AllRules.ruleset
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+
+
+ FreeSpaceWatcherWindow.xaml
+
+
+
+ ResXFileCodeGenerator
+ Designer
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.sln b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.sln
new file mode 100644
index 00000000..c7f009f7
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcher.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSpaceWatcher", "FreeSpaceWatcher.csproj", "{AC57A4BB-BCF4-49CC-832C-2C57F2F86322}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = http://silver:8080/
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = FreeSpaceWatcher.csproj
+ SccLocalPath1 = .
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AC57A4BB-BCF4-49CC-832C-2C57F2F86322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AC57A4BB-BCF4-49CC-832C-2C57F2F86322}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AC57A4BB-BCF4-49CC-832C-2C57F2F86322}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AC57A4BB-BCF4-49CC-832C-2C57F2F86322}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml
new file mode 100644
index 00000000..829559e8
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml.cs
new file mode 100644
index 00000000..79205760
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/FreeSpaceWatcherWindow.xaml.cs
@@ -0,0 +1,25 @@
+using System.IO;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Samples
+{
+ public partial class FreeSpaceWatcherWindow : System.Windows.Window
+ {
+ public FreeSpaceWatcherWindow()
+ {
+ InitializeComponent();
+ DrivesCombo.SelectionChanged += new SelectionChangedEventHandler(DrivesCombo_SelectionChanged);
+ }
+
+ private void DrivesCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ ((FreeSpaceInfo)FindResource("spaceInfo")).Drive = e.AddedItems[0].ToString();
+ }
+
+ public static DriveInfo[] Drives
+ {
+ get { return DriveInfo.GetDrives(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/AssemblyInfo.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..3b6ba2b2
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+#region Using directives
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Resources;
+using System.Globalization;
+using System.Windows;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FreeSpaceWatcher")]
+[assembly: AssemblyDescription("FreeSpaceWatcher Sample Application")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Software & Support Verlag GmbH")]
+[assembly: AssemblyProduct("WPF und XAML")]
+[assembly: AssemblyCopyright("Software & Support Verlag GmbH")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+// Specifies the location in which theme dictionaries are stored for types in an assembly.
+[assembly: ThemeInfo(
+ // Specifies the location of system theme-specific resource dictionaries for this project.
+ // The default setting in this project is "None" since this default project does not
+ // include these user-defined theme files:
+ // Themes\Aero.NormalColor.xaml
+ // Themes\Classic.xaml
+ // Themes\Luna.Homestead.xaml
+ // Themes\Luna.Metallic.xaml
+ // Themes\Luna.NormalColor.xaml
+ // Themes\Royale.NormalColor.xaml
+ ResourceDictionaryLocation.None,
+
+ // Specifies the location of the system non-theme specific resource dictionary:
+ // Themes\generic.xaml
+ ResourceDictionaryLocation.SourceAssembly)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.Designer.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..d09067ca
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace FreeSpaceWatcher.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FreeSpaceWatcher.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.resx b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.resx
new file mode 100644
index 00000000..27c69f67
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.Designer.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..cc6289c3
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace FreeSpaceWatcher.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.settings b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.settings
new file mode 100644
index 00000000..40246947
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/RatioToStringConverter.cs b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/RatioToStringConverter.cs
new file mode 100644
index 00000000..9fd1ea61
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/02 FreeSpaceWatcher - Step 1/RatioToStringConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Data;
+
+namespace Samples
+{
+ [ValueConversion(typeof(Double), typeof(String))]
+ public class RatioToStringConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return ((Double)value).ToString(parameter as String, culture.NumberFormat);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return System.Convert.ToDouble(value as string, culture.NumberFormat);
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.config b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.config
new file mode 100644
index 00000000..c5e1daef
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.config
@@ -0,0 +1,3 @@
+
+
+
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml
new file mode 100644
index 00000000..2f58701a
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml.cs
new file mode 100644
index 00000000..80888be1
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/App.xaml.cs
@@ -0,0 +1,8 @@
+using System.Windows;
+
+namespace FreeSpaceWatcher
+{
+ public partial class App : Application
+ {
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceInfo.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceInfo.cs
new file mode 100644
index 00000000..aed3d00b
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceInfo.cs
@@ -0,0 +1,54 @@
+using System;
+using System.IO;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Threading;
+
+namespace Samples
+{
+ public class FreeSpaceInfo : DependencyObject
+ {
+ private DriveInfo currentDriveInfo = null;
+
+ public FreeSpaceInfo()
+ {
+ }
+
+ #region "Drive" dependency property
+ public static readonly DependencyProperty DriveProperty =
+ DependencyProperty.Register("Drive", typeof(string), typeof(FreeSpaceInfo),
+ new PropertyMetadata( new PropertyChangedCallback(OnDriveChanged)));
+ public string Drive
+ {
+ get { return (string)GetValue(DriveProperty); }
+ set { SetValue(DriveProperty, value); }
+ }
+ public static void OnDriveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ FreeSpaceInfo o = (FreeSpaceInfo)d;
+ // check if the drive property is empty
+ if (((string)e.NewValue).Length > 0)
+ {
+ // get data about the drive
+ o.currentDriveInfo = new DriveInfo((string)e.NewValue);
+ // set dependency property
+ d.SetValue(FreeSpaceRatioProperty,
+ Convert.ToDouble(o.currentDriveInfo.TotalFreeSpace) / o.currentDriveInfo.TotalSize);
+ }
+ else
+ // no drive has been selected -> set free space ratio to zero
+ d.SetValue(FreeSpaceRatioProperty, 0.0);
+ }
+ #endregion
+
+ #region "FreeSpaceRatio" dependency property
+ public double FreeSpaceRatio
+ {
+ // this property is read only -> no set is implemented
+ get { return (double)GetValue(FreeSpaceRatioProperty); }
+ }
+ public static readonly DependencyProperty FreeSpaceRatioProperty =
+ DependencyProperty.Register("FreeSpaceRatio", typeof(double), typeof(FreeSpaceInfo));
+ #endregion
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.csproj b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.csproj
new file mode 100644
index 00000000..580e1b1f
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.csproj
@@ -0,0 +1,150 @@
+
+
+
+ Debug
+ AnyCPU
+ {0074CB79-EEC1-40F1-9601-4F9A429C4D5A}
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ FreeSpaceWatcher
+ FreeSpaceWatcher
+ 4
+ winexe
+ 3.0
+ false
+ SAK
+ SAK
+ SAK
+ SAK
+ v4.5
+
+
+ 3.5
+
+
+
+
+ Publish\
+ true
+ Web
+ true
+ Foreground
+ 7
+ Days
+ false
+ false
+ false
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+ true
+ full
+ false
+ .\bin\Debug\
+ DEBUG;TRACE
+ AllRules.ruleset
+ false
+
+
+ false
+ true
+ .\bin\Release\
+ TRACE
+ AllRules.ruleset
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+
+
+ FreeSpaceWatcherWindow.xaml
+
+
+
+ ResXFileCodeGenerator
+ Designer
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ True
+ Settings.settings
+
+
+ RatioPieChart.xaml
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.sln b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.sln
new file mode 100644
index 00000000..0690a65e
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcher.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSpaceWatcher", "FreeSpaceWatcher.csproj", "{0074CB79-EEC1-40F1-9601-4F9A429C4D5A}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = http://silver:8080/
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = FreeSpaceWatcher.csproj
+ SccLocalPath1 = .
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0074CB79-EEC1-40F1-9601-4F9A429C4D5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0074CB79-EEC1-40F1-9601-4F9A429C4D5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0074CB79-EEC1-40F1-9601-4F9A429C4D5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0074CB79-EEC1-40F1-9601-4F9A429C4D5A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml
new file mode 100644
index 00000000..df1aa8ff
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml.cs
new file mode 100644
index 00000000..79205760
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/FreeSpaceWatcherWindow.xaml.cs
@@ -0,0 +1,25 @@
+using System.IO;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Samples
+{
+ public partial class FreeSpaceWatcherWindow : System.Windows.Window
+ {
+ public FreeSpaceWatcherWindow()
+ {
+ InitializeComponent();
+ DrivesCombo.SelectionChanged += new SelectionChangedEventHandler(DrivesCombo_SelectionChanged);
+ }
+
+ private void DrivesCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ ((FreeSpaceInfo)FindResource("spaceInfo")).Drive = e.AddedItems[0].ToString();
+ }
+
+ public static DriveInfo[] Drives
+ {
+ get { return DriveInfo.GetDrives(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/AssemblyInfo.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..3b6ba2b2
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+#region Using directives
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Resources;
+using System.Globalization;
+using System.Windows;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FreeSpaceWatcher")]
+[assembly: AssemblyDescription("FreeSpaceWatcher Sample Application")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Software & Support Verlag GmbH")]
+[assembly: AssemblyProduct("WPF und XAML")]
+[assembly: AssemblyCopyright("Software & Support Verlag GmbH")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+// Specifies the location in which theme dictionaries are stored for types in an assembly.
+[assembly: ThemeInfo(
+ // Specifies the location of system theme-specific resource dictionaries for this project.
+ // The default setting in this project is "None" since this default project does not
+ // include these user-defined theme files:
+ // Themes\Aero.NormalColor.xaml
+ // Themes\Classic.xaml
+ // Themes\Luna.Homestead.xaml
+ // Themes\Luna.Metallic.xaml
+ // Themes\Luna.NormalColor.xaml
+ // Themes\Royale.NormalColor.xaml
+ ResourceDictionaryLocation.None,
+
+ // Specifies the location of the system non-theme specific resource dictionary:
+ // Themes\generic.xaml
+ ResourceDictionaryLocation.SourceAssembly)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.Designer.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..d09067ca
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace FreeSpaceWatcher.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FreeSpaceWatcher.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.resx b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.resx
new file mode 100644
index 00000000..27c69f67
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.Designer.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..cc6289c3
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace FreeSpaceWatcher.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.settings b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.settings
new file mode 100644
index 00000000..40246947
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml
new file mode 100644
index 00000000..e1481de6
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml
@@ -0,0 +1,27 @@
+
+
+
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml.cs
new file mode 100644
index 00000000..9ee9afa6
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioPieChart.xaml.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Controls;
+
+namespace Samples
+{
+ public partial class RatioPieChart : UserControl
+ {
+ public RatioPieChart()
+ {
+ InitializeComponent();
+ DataContext = this;
+ }
+
+ #region "Ratio" dependency property
+ public double Ratio
+ {
+ get { return (double)GetValue(RatioProperty); }
+ set { SetValue(RatioProperty, value); }
+ }
+ public static readonly DependencyProperty RatioProperty =
+ DependencyProperty.Register("Ratio", typeof(double), typeof(RatioPieChart),
+ new PropertyMetadata(new PropertyChangedCallback(OnRatioPropertyChanged)));
+ public static void OnRatioPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ RatioPieChart o = (RatioPieChart)d;
+ // calculate end point of arc
+ o.SetValue(PointProperty, new Point(50+Math.Cos((90 + 360 * o.Ratio)*Math.PI/180) * -50,
+ 50 - Math.Sin((90 + 360 * o.Ratio) * Math.PI / 180) * 50));
+ // calculate large arc flags
+ o.SetValue(IsLargeArcRatioProperty, o.Ratio >= 0.5 ? true : false);
+ o.SetValue(IsLargeArcRatioRest, o.Ratio < 0.5 ? true : false);
+ }
+ #endregion
+
+ #region "Point" dependency property
+ public Point Point
+ {
+ get { return (Point)GetValue(PointProperty); }
+ }
+ public static readonly DependencyProperty PointProperty =
+ DependencyProperty.Register("Point", typeof(Point), typeof(RatioPieChart),
+ new PropertyMetadata(new Point(50,0)));
+ #endregion
+
+ #region "IsLargeArcRatio" and "IsLargeArcRest" dependency properties
+ public Boolean IsLargeArcRatio
+ {
+ get { return (Boolean)GetValue(IsLargeArcRatioProperty); }
+ }
+ public static readonly DependencyProperty IsLargeArcRatioProperty =
+ DependencyProperty.Register("IsLargeArcRatio", typeof(Boolean), typeof(RatioPieChart),
+ new PropertyMetadata(false));
+
+ public Boolean IsLargeArcRest
+ {
+ get { return (Boolean)GetValue(IsLargeArcRatioRest); }
+ }
+ public static readonly DependencyProperty IsLargeArcRatioRest =
+ DependencyProperty.Register("IsLargeArcRest", typeof(Boolean), typeof(RatioPieChart),
+ new PropertyMetadata(true));
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioToStringConverter.cs b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioToStringConverter.cs
new file mode 100644
index 00000000..9fd1ea61
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/03 FreeSpaceWatcher - Step 2/RatioToStringConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Data;
+
+namespace Samples
+{
+ [ValueConversion(typeof(Double), typeof(String))]
+ public class RatioToStringConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return ((Double)value).ToString(parameter as String, culture.NumberFormat);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return System.Convert.ToDouble(value as string, culture.NumberFormat);
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.config b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.config
new file mode 100644
index 00000000..c5e1daef
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.config
@@ -0,0 +1,3 @@
+
+
+
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml
new file mode 100644
index 00000000..2f58701a
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml.cs
new file mode 100644
index 00000000..8249e9d0
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/App.xaml.cs
@@ -0,0 +1,32 @@
+using System.Windows;
+using System.Threading;
+
+namespace FreeSpaceWatcher
+{
+ public partial class App : Application
+ {
+ private DispatcherQueue dispatcherQueueForm;
+ private Thread queueThread;
+
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ base.OnStartup(e);
+
+ // start a new thread for the window monitoring the dispatcher
+ queueThread = new Thread(new ParameterizedThreadStart(QueueThreadProc));
+ queueThread.SetApartmentState(ApartmentState.STA);
+ queueThread.IsBackground = true;
+ // pass the dispatcher of the main window as a parameter to the new thread
+ queueThread.Start(Dispatcher);
+ }
+
+ private void QueueThreadProc( object dispatcher )
+ {
+ // start window in new thread
+ dispatcherQueueForm = new DispatcherQueue((System.Windows.Threading.Dispatcher)dispatcher);
+ dispatcherQueueForm.Show();
+ // a dispatcher is automatically created by WPF
+ System.Windows.Threading.Dispatcher.Run();
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml
new file mode 100644
index 00000000..4ec1f8f4
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml.cs
new file mode 100644
index 00000000..a6ea339b
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/DispatcherQueue.xaml.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Threading;
+
+namespace FreeSpaceWatcher
+{
+ public partial class DispatcherQueue : Window
+ {
+ private delegate void QueueEventsDelegate();
+ private DispatcherTimer perSecondTimer;
+ private int lastCounterValue = 0;
+ private System.Windows.Threading.Dispatcher dispatcher;
+
+ public DispatcherQueue(System.Windows.Threading.Dispatcher dispatcher)
+ {
+ InitializeComponent();
+
+ // set data context to enable binding
+ DataContext = this;
+
+ // start a timer that is used to update the input field every second
+ perSecondTimer = new DispatcherTimer(DispatcherPriority.Normal);
+ perSecondTimer.Tick += new EventHandler(perSecondTimer_Tick);
+ perSecondTimer.Interval = new TimeSpan(0, 0, 1);
+ perSecondTimer.Start();
+
+ // remember the dispatcher that should be monitored
+ this.dispatcher = dispatcher;
+ // add a hook to the dispatcher that is monitored
+ dispatcher.Hooks.OperationPosted += new System.Windows.Threading.DispatcherHookEventHandler(Hooks_OperationPosted);
+ }
+
+ void perSecondTimer_Tick(object sender, EventArgs e)
+ {
+ // set the dependency property
+ SetValue(OperationsPerSecondCounterProperty, TotalOperationsCounter - lastCounterValue);
+ // remember the last value for next second
+ lastCounterValue = TotalOperationsCounter;
+ }
+
+ void Hooks_OperationPosted(object sender, System.Windows.Threading.DispatcherHookEventArgs e)
+ {
+ // this event handler runs in a separate thread; therefore we have to use
+ // the window's dispatcher queue to schedule a procedure incrementing
+ // the counter (=a dependency property).
+ Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
+ new QueueEventsDelegate(IncrementOperationsCounter));
+ }
+
+ private void IncrementOperationsCounter()
+ {
+ // increment the dependency property
+ SetValue(TotalOperationsCounterProperty, TotalOperationsCounter + 1);
+ }
+
+ #region "TotalOperationsCounter" dependency property
+ public int TotalOperationsCounter
+ {
+ get { return (int)GetValue(TotalOperationsCounterProperty); }
+ }
+ public static readonly DependencyProperty TotalOperationsCounterProperty =
+ DependencyProperty.Register("TotalOperationsCounter", typeof(int), typeof(DispatcherQueue),
+ new PropertyMetadata(0));
+ #endregion
+
+ #region "OperationsPerSecondCounter" dependency property
+ public int OperationsPerSecondCounter
+ {
+ get { return (int)GetValue(OperationsPerSecondCounterProperty); }
+ }
+ public static readonly DependencyProperty OperationsPerSecondCounterProperty =
+ DependencyProperty.Register("OperationsPerSecondCounter", typeof(int), typeof(DispatcherQueue),
+ new PropertyMetadata(0));
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfo.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfo.cs
new file mode 100644
index 00000000..cfead586
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfo.cs
@@ -0,0 +1,80 @@
+using System;
+using System.IO;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Threading;
+
+namespace Samples
+{
+ public class FreeSpaceInfo : DependencyObject
+ {
+ private DispatcherTimer monitorFreeSpaceTimer;
+ private DriveInfo currentDriveInfo = null;
+
+ public FreeSpaceInfo()
+ {
+ // start a timer that monitors the free disk space every second
+ monitorFreeSpaceTimer = new DispatcherTimer();
+ monitorFreeSpaceTimer.Tick += new EventHandler(freeSpaceMonitorTimer_Tick);
+ monitorFreeSpaceTimer.Interval = new TimeSpan(0, 0, 1);
+ monitorFreeSpaceTimer.Start();
+ }
+
+ private void freeSpaceMonitorTimer_Tick(object sender, EventArgs e)
+ {
+ // stop timer while processing
+ monitorFreeSpaceTimer.Stop();
+
+ // has the drive-property been set?
+ if (currentDriveInfo != null)
+ {
+ // calculate the free space ratio
+ double newRatio = Convert.ToDouble(currentDriveInfo.TotalFreeSpace) / currentDriveInfo.TotalSize;
+ // check if free space ratio has changed
+ if (newRatio != FreeSpaceRatio)
+ // set dependency property
+ SetValue(FreeSpaceRatioProperty, newRatio);
+ }
+
+ // start timer after processing
+ monitorFreeSpaceTimer.Start();
+ }
+
+ #region "Drive" dependency property
+ public static readonly DependencyProperty DriveProperty =
+ DependencyProperty.Register("Drive", typeof(string), typeof(FreeSpaceInfo),
+ new PropertyMetadata( new PropertyChangedCallback(OnDriveChanged)));
+ public string Drive
+ {
+ get { return (string)GetValue(DriveProperty); }
+ set { SetValue(DriveProperty, value); }
+ }
+ public static void OnDriveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ FreeSpaceInfo o = (FreeSpaceInfo)d;
+ // check if the drive property is empty
+ if (((string)e.NewValue).Length > 0)
+ {
+ // get data about the drive
+ o.currentDriveInfo = new DriveInfo((string)e.NewValue);
+ // set dependency property
+ d.SetValue(FreeSpaceRatioProperty,
+ Convert.ToDouble(o.currentDriveInfo.TotalFreeSpace) / o.currentDriveInfo.TotalSize);
+ }
+ else
+ // no drive has been selected -> set free space ratio to zero
+ d.SetValue(FreeSpaceRatioProperty, 0.0);
+ }
+ #endregion
+
+ #region "FreeSpaceRatio" dependency property
+ public double FreeSpaceRatio
+ {
+ // this property is read only -> no set is implemented
+ get { return (double)GetValue(FreeSpaceRatioProperty); }
+ }
+ public static readonly DependencyProperty FreeSpaceRatioProperty =
+ DependencyProperty.Register("FreeSpaceRatio", typeof(double), typeof(FreeSpaceInfo));
+ #endregion
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfoWithoutTimer.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfoWithoutTimer.cs
new file mode 100644
index 00000000..03f15ba9
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceInfoWithoutTimer.cs
@@ -0,0 +1,73 @@
+using System;
+using System.IO;
+using System.Windows;
+using System.ComponentModel;
+using System.Windows.Threading;
+
+namespace Samples
+{
+ public class FreeSpaceInfoWithoutTimer : DependencyObject
+ {
+ private delegate void UpdateFreeSpaceDelegate();
+ private DriveInfo currentDriveInfo = null;
+
+ public FreeSpaceInfoWithoutTimer()
+ {
+ Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle,
+ new UpdateFreeSpaceDelegate(UpdateFreeSpace));
+ }
+
+ private void UpdateFreeSpace()
+ {
+ // has the drive-property been set?
+ if (currentDriveInfo != null)
+ {
+ // calculate the free space ratio
+ double newRatio = Convert.ToDouble(currentDriveInfo.TotalFreeSpace) / currentDriveInfo.TotalSize;
+ // check if free space ratio has changed
+ if (newRatio != FreeSpaceRatio)
+ // set dependency property
+ SetValue(FreeSpaceRatioProperty, newRatio);
+ }
+ Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle,
+ new UpdateFreeSpaceDelegate(UpdateFreeSpace));
+ }
+
+ #region "Drive" dependency property
+ public static readonly DependencyProperty DriveProperty =
+ DependencyProperty.Register("Drive", typeof(string), typeof(FreeSpaceInfo),
+ new PropertyMetadata( new PropertyChangedCallback(OnDriveChanged)));
+ public string Drive
+ {
+ get { return (string)GetValue(DriveProperty); }
+ set { SetValue(DriveProperty, value); }
+ }
+ public static void OnDriveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ FreeSpaceInfoWithoutTimer o = (FreeSpaceInfoWithoutTimer)d;
+ // check if the drive property is empty
+ if (((string)e.NewValue).Length > 0)
+ {
+ // get data about the drive
+ o.currentDriveInfo = new DriveInfo((string)e.NewValue);
+ // set dependency property
+ d.SetValue(FreeSpaceRatioProperty,
+ Convert.ToDouble(o.currentDriveInfo.TotalFreeSpace) / o.currentDriveInfo.TotalSize);
+ }
+ else
+ // no drive has been selected -> set free space ratio to zero
+ d.SetValue(FreeSpaceRatioProperty, 0.0);
+ }
+ #endregion
+
+ #region "FreeSpaceRatio" dependency property
+ public double FreeSpaceRatio
+ {
+ // this property is read only -> no set is implemented
+ get { return (double)GetValue(FreeSpaceRatioProperty); }
+ }
+ public static readonly DependencyProperty FreeSpaceRatioProperty =
+ DependencyProperty.Register("FreeSpaceRatio", typeof(double), typeof(FreeSpaceInfo));
+ #endregion
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.csproj b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.csproj
new file mode 100644
index 00000000..0fd33a95
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.csproj
@@ -0,0 +1,162 @@
+
+
+
+ Debug
+ AnyCPU
+ {82F168DA-597C-43E1-B849-3ED06372E335}
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Samples
+ FreeSpaceWatcher
+ 4
+ winexe
+ 3.0
+ false
+ SAK
+ SAK
+ SAK
+ SAK
+ v4.5
+
+
+ 3.5
+
+
+
+
+ Publish\
+ true
+ Web
+ true
+ Foreground
+ 7
+ Days
+ false
+ false
+ false
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+ true
+ full
+ false
+ .\bin\Debug\
+ DEBUG;TRACE
+ AllRules.ruleset
+ false
+
+
+ false
+ true
+ .\bin\Release\
+ TRACE
+ AllRules.ruleset
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ FreeSpaceWatcherWindow.xaml
+ Code
+
+
+
+
+
+ Code
+ DispatcherQueue.xaml
+
+
+
+
+ ResXFileCodeGenerator
+ Designer
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ True
+ Settings.settings
+
+
+ Code
+ RatioPieChart.xaml
+
+
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.sln b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.sln
new file mode 100644
index 00000000..aa2453fe
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcher.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSpaceWatcher", "FreeSpaceWatcher.csproj", "{82F168DA-597C-43E1-B849-3ED06372E335}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = http://silver:8080/
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = FreeSpaceWatcher.csproj
+ SccLocalPath1 = .
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {82F168DA-597C-43E1-B849-3ED06372E335}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {82F168DA-597C-43E1-B849-3ED06372E335}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {82F168DA-597C-43E1-B849-3ED06372E335}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {82F168DA-597C-43E1-B849-3ED06372E335}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml
new file mode 100644
index 00000000..02317438
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml.cs
new file mode 100644
index 00000000..66d8ec69
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/FreeSpaceWatcherWindow.xaml.cs
@@ -0,0 +1,25 @@
+using System.IO;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Samples
+{
+ public partial class FreeSpaceWatcherWindow : System.Windows.Window
+ {
+ public FreeSpaceWatcherWindow()
+ {
+ InitializeComponent();
+ //DrivesCombo.SelectionChanged += new SelectionChangedEventHandler(DrivesCombo_SelectionChanged);
+ }
+
+ //private void DrivesCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ //{
+ // ((FreeSpaceInfo)FindResource("spaceInfo")).Drive = e.AddedItems[0].ToString();
+ //}
+
+ public static DriveInfo[] Drives
+ {
+ get { return DriveInfo.GetDrives(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/AssemblyInfo.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..3b6ba2b2
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+#region Using directives
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Resources;
+using System.Globalization;
+using System.Windows;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FreeSpaceWatcher")]
+[assembly: AssemblyDescription("FreeSpaceWatcher Sample Application")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Software & Support Verlag GmbH")]
+[assembly: AssemblyProduct("WPF und XAML")]
+[assembly: AssemblyCopyright("Software & Support Verlag GmbH")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+// Specifies the location in which theme dictionaries are stored for types in an assembly.
+[assembly: ThemeInfo(
+ // Specifies the location of system theme-specific resource dictionaries for this project.
+ // The default setting in this project is "None" since this default project does not
+ // include these user-defined theme files:
+ // Themes\Aero.NormalColor.xaml
+ // Themes\Classic.xaml
+ // Themes\Luna.Homestead.xaml
+ // Themes\Luna.Metallic.xaml
+ // Themes\Luna.NormalColor.xaml
+ // Themes\Royale.NormalColor.xaml
+ ResourceDictionaryLocation.None,
+
+ // Specifies the location of the system non-theme specific resource dictionary:
+ // Themes\generic.xaml
+ ResourceDictionaryLocation.SourceAssembly)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.Designer.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..a548ccf5
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Samples.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Samples.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.resx b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.resx
new file mode 100644
index 00000000..27c69f67
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.Designer.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..f6b9b89e
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Samples.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.settings b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.settings
new file mode 100644
index 00000000..40246947
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml
new file mode 100644
index 00000000..e1481de6
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml
@@ -0,0 +1,27 @@
+
+
+
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml.cs
new file mode 100644
index 00000000..e0078ca4
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioPieChart.xaml.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Windows;
+using System.ComponentModel;
+
+namespace Samples
+{
+ public partial class RatioPieChart : System.Windows.Controls.UserControl
+ {
+ public RatioPieChart()
+ {
+ InitializeComponent();
+ DataContext = this;
+ }
+
+ #region "Ratio" dependency property
+ public double Ratio
+ {
+ get { return (double)GetValue(RatioProperty); }
+ set { SetValue(RatioProperty, value); }
+ }
+ public static readonly DependencyProperty RatioProperty =
+ DependencyProperty.Register("Ratio", typeof(double), typeof(RatioPieChart),
+ new PropertyMetadata(new PropertyChangedCallback(OnRatioPropertyChanged)));
+ public static void OnRatioPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ RatioPieChart o = (RatioPieChart)d;
+ // calculate end point of arc
+ o.SetValue(PointProperty, new Point(50+Math.Cos((90 + 360 * o.Ratio)*Math.PI/180) * -50,
+ 50 - Math.Sin((90 + 360 * o.Ratio) * Math.PI / 180) * 50));
+ // calculate large arc flags
+ o.SetValue(IsLargeArcRatioProperty, o.Ratio >= 0.5 ? true : false);
+ o.SetValue(IsLargeArcRatioRest, o.Ratio < 0.5 ? true : false);
+ }
+ #endregion
+
+ #region "Point" dependency property
+ public Point Point
+ {
+ get { return (Point)GetValue(PointProperty); }
+ }
+ public static readonly DependencyProperty PointProperty =
+ DependencyProperty.Register("Point", typeof(Point), typeof(RatioPieChart),
+ new PropertyMetadata(new Point(50,0)));
+ #endregion
+
+ #region "IsLargeArcRatio" and "IsLargeArcRest" dependency properties
+ public Boolean IsLargeArcRatio
+ {
+ get { return (Boolean)GetValue(IsLargeArcRatioProperty); }
+ }
+ public static readonly DependencyProperty IsLargeArcRatioProperty =
+ DependencyProperty.Register("IsLargeArcRatio", typeof(Boolean), typeof(RatioPieChart),
+ new PropertyMetadata(false));
+
+ public Boolean IsLargeArcRest
+ {
+ get { return (Boolean)GetValue(IsLargeArcRatioRest); }
+ }
+ public static readonly DependencyProperty IsLargeArcRatioRest =
+ DependencyProperty.Register("IsLargeArcRest", typeof(Boolean), typeof(RatioPieChart),
+ new PropertyMetadata(true));
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioToStringConverter.cs b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioToStringConverter.cs
new file mode 100644
index 00000000..9fd1ea61
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/04 FreeSpaceWatcher - Step 3/RatioToStringConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Data;
+
+namespace Samples
+{
+ [ValueConversion(typeof(Double), typeof(String))]
+ public class RatioToStringConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return ((Double)value).ToString(parameter as String, culture.NumberFormat);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter,
+ System.Globalization.CultureInfo culture)
+ {
+ return System.Convert.ToDouble(value as string, culture.NumberFormat);
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.config b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.config
new file mode 100644
index 00000000..863b3699
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+ http://www.webservicex.net/stockquote.asmx
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml
new file mode 100644
index 00000000..b9c1467b
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml.cs
new file mode 100644
index 00000000..491316be
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/App.xaml.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Windows;
+using System.Data;
+using System.Xml;
+using System.Configuration;
+
+namespace Samples
+{
+ public partial class App : System.Windows.Application
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml
new file mode 100644
index 00000000..5dccef54
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml.cs
new file mode 100644
index 00000000..c3033cb5
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToADO.xaml.cs
@@ -0,0 +1,20 @@
+using System.Windows.Controls;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace Samples
+{
+ public partial class BindToADO : Page
+ {
+ public BindToADO()
+ {
+ InitializeComponent();
+ ((SqlConnection)FindResource("Connection")).Open();
+
+ DataSet result = (DataSet)FindResource("Data");
+ ((SqlDataAdapter)FindResource("DataAdapter")).Fill(result, "Person");
+
+ DataList.DataContext = result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml
new file mode 100644
index 00000000..0504cbb1
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml.cs
new file mode 100644
index 00000000..6f1d0554
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToCollection.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindToCollection.xaml
+ ///
+
+ public partial class BindToCollection : System.Windows.Controls.Page
+ {
+ public BindToCollection()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml
new file mode 100644
index 00000000..85d0e1ca
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+ c:\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml.cs
new file mode 100644
index 00000000..eb99a283
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToMethodResult.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindToMethodResult.xaml
+ ///
+
+ public partial class BindToMethodResult : System.Windows.Controls.Page
+ {
+ public BindToMethodResult()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml
new file mode 100644
index 00000000..df359bd3
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml.cs
new file mode 100644
index 00000000..69fc7b00
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToObjectInResource.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindToObjectInResource.xaml
+ ///
+
+ public partial class BindToObjectInResource : System.Windows.Controls.Page
+ {
+ public BindToObjectInResource()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml
new file mode 100644
index 00000000..21901a53
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml.cs
new file mode 100644
index 00000000..a7172337
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToSource.xaml.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindToSource.xaml
+ ///
+
+ public partial class BindToSource : System.Windows.Controls.Page
+ {
+ public BindToSource()
+ {
+ InitializeComponent();
+ ShowLastName.Click += new RoutedEventHandler(ShowLastName_Click);
+ }
+
+ void ShowLastName_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show(((Person)FindResource("Person")).LastName);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml
new file mode 100644
index 00000000..ff22a88c
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+ MSFT
+ AAPL
+ IBM
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml.cs
new file mode 100644
index 00000000..775b9d86
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindToXml.xaml.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Windows.Controls;
+using System.Xml;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Samples
+{
+ public partial class BindToXml : Page
+ {
+ public BindToXml()
+ {
+ InitializeComponent();
+ DataContext = this;
+ }
+
+ public String StockSymbol
+ {
+ get { return (String)GetValue(StockSymbolProperty); }
+ set { SetValue(StockSymbolProperty, value); }
+ }
+ public static readonly DependencyProperty StockSymbolProperty =
+ DependencyProperty.Register("StockSymbol", typeof(String), typeof(BindToXml),
+ new PropertyMetadata("", new PropertyChangedCallback(OnStockSymbolChanged)));
+ private static void OnStockSymbolChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
+ {
+ BindToXml d = sender as BindToXml;
+ if (d.StockSymbol.Length > 0)
+ {
+ StockQuoteService.StockQuote service = new Samples.StockQuoteService.StockQuote();
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(service.GetQuote(d.StockSymbol));
+ ((XmlDataProvider)d.FindResource("MarketDataXml")).Document = doc;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml
new file mode 100644
index 00000000..a2a97071
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml.cs
new file mode 100644
index 00000000..5109cebd
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindTwoControls.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindTwoControls.xaml
+ ///
+
+ public partial class BindTwoControls : System.Windows.Controls.Page
+ {
+ public BindTwoControls()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml
new file mode 100644
index 00000000..56ec8d2a
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml.cs
new file mode 100644
index 00000000..f8451490
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingExpressions.xaml.cs
@@ -0,0 +1,33 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace Samples
+{
+ public partial class BindingExpressions : Page
+ {
+ public BindingExpressions()
+ {
+ InitializeComponent();
+ WriteDataToSource.Click += new RoutedEventHandler(WriteDataToSource_Click);
+
+ Binding myBinding = new Binding("LastName");
+ myBinding.Source = FindResource("Person");
+ myBinding.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus;
+ LostFocusBox.SetBinding(TextBox.TextProperty, myBinding);
+ LostFocusTextBlock.SetBinding(TextBlock.TextProperty, myBinding);
+
+ BindingExpression textBoxExpression =
+ LostFocusBox.GetBindingExpression(TextBox.TextProperty);
+ BindingExpression textBlockExpression =
+ LostFocusTextBlock.GetBindingExpression(TextBlock.TextProperty);
+ }
+
+ void WriteDataToSource_Click(object sender, RoutedEventArgs e)
+ {
+ BindingExpression expr = ExplicitBox.GetBindingExpression(TextBox.TextProperty);
+ expr.UpdateSource();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml
new file mode 100644
index 00000000..b179c9d2
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml.cs
new file mode 100644
index 00000000..5f8e3d00
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/BindingValidation.xaml.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for BindToSource.xaml
+ ///
+
+ public partial class BindingValidation : System.Windows.Controls.Page
+ {
+ public BindingValidation()
+ {
+ InitializeComponent();
+ this.DataContext = this;
+ }
+
+ public TimeSpan ResultTime { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml
new file mode 100644
index 00000000..37b97d7f
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+ c:\
+
+
+
+
+ c:\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml.cs
new file mode 100644
index 00000000..bf01b505
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/CombineCollectionsInBinding.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for CombineCollectionsInBinding.xaml
+ ///
+
+ public partial class CombineCollectionsInBinding : System.Windows.Controls.Page
+ {
+ public CombineCollectionsInBinding()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml
new file mode 100644
index 00000000..e9da5c31
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml.cs
new file mode 100644
index 00000000..8ccc7bd6
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingNotification.xaml.cs
@@ -0,0 +1,68 @@
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Collections.ObjectModel;
+
+namespace Samples
+{
+ public partial class DataBindingNotification : Page
+ {
+ private List personList = new List();
+ private ObservableCollection personObservableList = new ObservableCollection();
+
+ public DataBindingNotification()
+ {
+ InitializeComponent();
+
+ Person newPerson = new Person();
+ newPerson.FirstName = "Rainer";
+ newPerson.LastName = "Stropek";
+ personList.Add(newPerson);
+
+ newPerson = new Person();
+ newPerson.FirstName = "Karin";
+ newPerson.LastName = "Huber";
+ personObservableList.Add(newPerson);
+
+ ListListbox.ItemsSource = personList;
+ ObservableListListbox.ItemsSource = personObservableList;
+
+ AddPersonListListbox.Click += new RoutedEventHandler(AddPersonListListbox_Click);
+ AddPersonObservableListListbox.Click += new RoutedEventHandler(AddPersonObservableListListbox_Click);
+
+ ChangePerson.Click += new RoutedEventHandler(ChangePerson_Click);
+ ChangeNotifyingPerson.Click += new RoutedEventHandler(ChangeNotifyingPerson_Click);
+ }
+
+ void ChangeNotifyingPerson_Click(object sender, RoutedEventArgs e)
+ {
+ NotifyingPerson person = FindResource("NotifyingPerson") as NotifyingPerson;
+ person.FirstName = person.FirstName + " 2";
+ person.LastName = person.LastName + " 2";
+ }
+
+ void ChangePerson_Click(object sender, RoutedEventArgs e)
+ {
+ Person person = FindResource("Person") as Person;
+ person.FirstName = person.FirstName + " 2";
+ person.LastName = person.LastName + " 2";
+ }
+
+ void AddPersonObservableListListbox_Click(object sender, RoutedEventArgs e)
+ {
+ Person newPerson = new Person();
+ newPerson.FirstName = "Rainer";
+ newPerson.LastName = "Stropek";
+ personObservableList.Add(newPerson);
+ }
+
+ void AddPersonListListbox_Click(object sender, RoutedEventArgs e)
+ {
+ Person newPerson = new Person();
+ newPerson.FirstName = "Karin";
+ newPerson.LastName = "Huber";
+ personList.Add(newPerson);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.csproj b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.csproj
new file mode 100644
index 00000000..d27336ea
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.csproj
@@ -0,0 +1,289 @@
+
+
+
+ Debug
+ AnyCPU
+ {A10F1712-50C6-44C8-AAF1-DB1714696D75}
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Samples
+ DataBindingSzenarios
+ 4
+ winexe
+ 3.0
+ false
+ SAK
+ SAK
+ SAK
+ SAK
+ v4.5
+
+
+ 3.5
+
+
+
+
+ Publish\
+ true
+ Web
+ true
+ Foreground
+ 7
+ Days
+ false
+ false
+ false
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+ true
+ full
+ false
+ .\bin\Debug\
+ DEBUG;TRACE
+ AllRules.ruleset
+ false
+
+
+ false
+ true
+ .\bin\Release\
+ TRACE
+ AllRules.ruleset
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ BindingValidation.xaml
+
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+ BindingExpressions.xaml
+
+
+ Code
+ BindToADO.xaml
+
+
+ Code
+ BindToCollection.xaml
+
+
+ Code
+ BindToMethodResult.xaml
+
+
+ Code
+ BindToObjectInResource.xaml
+
+
+ Code
+ BindToSource.xaml
+
+
+ Code
+ BindToXml.xaml
+
+
+ Code
+ BindTwoControls.xaml
+
+
+ Code
+ CombineCollectionsInBinding.xaml
+
+
+ Code
+ DataBindingNotification.xaml
+
+
+ Code
+ MasterDetailBinding.xaml
+
+
+
+
+
+ ResXFileCodeGenerator
+ Designer
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ MSDiscoCodeGenerator
+ Reference.cs
+
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+ True
+ True
+ Reference.map
+
+
+
+
+
+
+
+
+ Dynamic
+ Web References\StockQuoteService\
+ http://www.webservicex.net/stockquote.asmx%3fwsdl
+
+
+
+
+ Settings
+ DataBindingSzenarios_StockQuoteService_StockQuote
+
+
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ true
+
+
+ False
+ Windows Installer 3.1
+ true
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.sln b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.sln
new file mode 100644
index 00000000..2970a1ea
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/DataBindingSzenarios.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataBindingSzenarios", "DataBindingSzenarios.csproj", "{A10F1712-50C6-44C8-AAF1-DB1714696D75}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = http://silver:8080/
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = DataBindingSzenarios.csproj
+ SccLocalPath1 = .
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A10F1712-50C6-44C8-AAF1-DB1714696D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A10F1712-50C6-44C8-AAF1-DB1714696D75}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A10F1712-50C6-44C8-AAF1-DB1714696D75}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A10F1712-50C6-44C8-AAF1-DB1714696D75}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/IsEnabledConverter.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/IsEnabledConverter.cs
new file mode 100644
index 00000000..d6de9e93
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/IsEnabledConverter.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Data;
+
+namespace SkiResults.Converter
+{
+ public class IsEnabledConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ bool isEnabled = true;
+
+ foreach (var item in values)
+ {
+ isEnabled &= (int)item == 0;
+ }
+
+ return isEnabled;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml
new file mode 100644
index 00000000..2470f7ec
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml.cs
new file mode 100644
index 00000000..af3706e6
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MainWindow.xaml.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+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 System.Windows.Markup;
+
+
+namespace Samples
+{
+ public partial class MainWindow : Window
+ {
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml
new file mode 100644
index 00000000..9f376e73
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml
@@ -0,0 +1,77 @@
+
+
+
+
+ c:\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml.cs
new file mode 100644
index 00000000..90f92625
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/MasterDetailBinding.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Samples
+{
+ ///
+ /// Interaction logic for MasterDetailBinding.xaml
+ ///
+
+ public partial class MasterDetailBinding : System.Windows.Controls.Page
+ {
+ public MasterDetailBinding()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/NotifyingPerson.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/NotifyingPerson.cs
new file mode 100644
index 00000000..0182c487
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/NotifyingPerson.cs
@@ -0,0 +1,31 @@
+using System.ComponentModel;
+
+namespace Samples
+{
+ class NotifyingPerson : Person, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public override string FirstName
+ {
+ get { return base.FirstName; }
+ set
+ {
+ base.FirstName = value;
+ if (PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
+ }
+ }
+
+ public override string LastName
+ {
+ get { return base.LastName; }
+ set
+ {
+ base.LastName = value;
+ if (PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs("LastName"));
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Person.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Person.cs
new file mode 100644
index 00000000..5b03b93e
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Person.cs
@@ -0,0 +1,52 @@
+using System;
+
+namespace Samples
+{
+ public class Person
+ {
+ private string firstName;
+ private string lastName;
+ private DateTime birthday;
+ private bool isMarried;
+ private int numberOfChildren;
+
+ public Person()
+ {
+ }
+
+ public virtual string FirstName
+ {
+ get { return firstName; }
+ set { firstName = value; }
+ }
+
+ public virtual string LastName
+ {
+ get { return lastName; }
+ set { lastName = value; }
+ }
+
+ public virtual DateTime Birthday
+ {
+ get { return birthday; }
+ set { birthday = value; }
+ }
+
+ public virtual bool IsMarried
+ {
+ get { return isMarried; }
+ set { isMarried = value; }
+ }
+
+ public virtual int NumberOfChildren
+ {
+ get { return numberOfChildren; }
+ set { numberOfChildren = value; }
+ }
+
+ public override string ToString()
+ {
+ return FirstName + ' ' + LastName;
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/AssemblyInfo.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..52b15daf
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+#region Using directives
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Resources;
+using System.Globalization;
+using System.Windows;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DataBindingSzenarios")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("DataBindingSzenarios")]
+[assembly: AssemblyCopyright("Copyright @ Microsoft 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+// Specifies the location in which theme dictionaries are stored for types in an assembly.
+[assembly: ThemeInfo(
+ // Specifies the location of system theme-specific resource dictionaries for this project.
+ // The default setting in this project is "None" since this default project does not
+ // include these user-defined theme files:
+ // Themes\Aero.NormalColor.xaml
+ // Themes\Classic.xaml
+ // Themes\Luna.Homestead.xaml
+ // Themes\Luna.Metallic.xaml
+ // Themes\Luna.NormalColor.xaml
+ // Themes\Royale.NormalColor.xaml
+ ResourceDictionaryLocation.None,
+
+ // Specifies the location of the system non-theme specific resource dictionary:
+ // Themes\generic.xaml
+ ResourceDictionaryLocation.SourceAssembly)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.Designer.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..a548ccf5
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Samples.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Samples.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.resx b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.resx
new file mode 100644
index 00000000..27c69f67
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.Designer.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..2aa3d5ef
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.Designer.cs
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Samples.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
+ [global::System.Configuration.DefaultSettingValueAttribute("http://www.webservicex.net/stockquote.asmx")]
+ public string DataBindingSzenarios_StockQuoteService_StockQuote {
+ get {
+ return ((string)(this["DataBindingSzenarios_StockQuoteService_StockQuote"]));
+ }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.settings b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.settings
new file mode 100644
index 00000000..ca452085
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Properties/Settings.settings
@@ -0,0 +1,9 @@
+
+
+
+
+
+ http://www.webservicex.net/stockquote.asmx
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Szenario.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Szenario.cs
new file mode 100644
index 00000000..642a5aed
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Szenario.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Samples
+{
+ class Szenario
+ {
+ private string description;
+ private string sourceUri;
+
+ public Szenario()
+ {
+ }
+
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+
+ public string SourceUri
+ {
+ get { return sourceUri; }
+ set { sourceUri = value; }
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/TimeToStringConverter.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/TimeToStringConverter.cs
new file mode 100644
index 00000000..6f161150
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/TimeToStringConverter.cs
@@ -0,0 +1,58 @@
+using System.Windows.Data;
+using System;
+using System.Windows.Controls;
+
+namespace Samples
+{
+ public class TimeToStringConverter : ValidationRule, IValueConverter
+ {
+ public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ {
+ return "";
+ }
+
+ if (!(value is TimeSpan))
+ {
+ throw new ArgumentException("Parameter value is not of type TimeSpan.", "value");
+ }
+
+ var timespan = (TimeSpan)value;
+ return timespan.Minutes.ToString() + ":" + timespan.Seconds.ToString("00") + "." + ((int)timespan.Milliseconds / 10).ToString("00");
+ }
+
+ public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+
+ if (!(value is string))
+ {
+ throw new ArgumentException("Parameter value is not of type string.", "value");
+ }
+
+ if (string.IsNullOrEmpty((string)value))
+ {
+ return null;
+ }
+
+ if (this.Validate(value, culture).IsValid)
+ {
+ return TimeSpan.Parse("00:0" + (string)value);
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
+ {
+ TimeSpan result;
+ return new ValidationResult(TimeSpan.TryParse("00:0" + (string)value, out result), "The string is in incorrect format");
+ }
+ }
+}
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/Reference.cs b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/Reference.cs
new file mode 100644
index 00000000..aa376db4
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/Reference.cs
@@ -0,0 +1,150 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18051
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+//
+// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.18051.
+//
+#pragma warning disable 1591
+
+namespace Samples.StockQuoteService {
+ using System;
+ using System.Web.Services;
+ using System.Diagnostics;
+ using System.Web.Services.Protocols;
+ using System.Xml.Serialization;
+ using System.ComponentModel;
+
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ [System.Web.Services.WebServiceBindingAttribute(Name="StockQuoteSoap", Namespace="http://www.webserviceX.NET/")]
+ public partial class StockQuote : System.Web.Services.Protocols.SoapHttpClientProtocol {
+
+ private System.Threading.SendOrPostCallback GetQuoteOperationCompleted;
+
+ private bool useDefaultCredentialsSetExplicitly;
+
+ ///
+ public StockQuote() {
+ this.Url = global::Samples.Properties.Settings.Default.DataBindingSzenarios_StockQuoteService_StockQuote;
+ if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
+ this.UseDefaultCredentials = true;
+ this.useDefaultCredentialsSetExplicitly = false;
+ }
+ else {
+ this.useDefaultCredentialsSetExplicitly = true;
+ }
+ }
+
+ public new string Url {
+ get {
+ return base.Url;
+ }
+ set {
+ if ((((this.IsLocalFileSystemWebService(base.Url) == true)
+ && (this.useDefaultCredentialsSetExplicitly == false))
+ && (this.IsLocalFileSystemWebService(value) == false))) {
+ base.UseDefaultCredentials = false;
+ }
+ base.Url = value;
+ }
+ }
+
+ public new bool UseDefaultCredentials {
+ get {
+ return base.UseDefaultCredentials;
+ }
+ set {
+ base.UseDefaultCredentials = value;
+ this.useDefaultCredentialsSetExplicitly = true;
+ }
+ }
+
+ ///
+ public event GetQuoteCompletedEventHandler GetQuoteCompleted;
+
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetQuote", RequestNamespace="http://www.webserviceX.NET/", ResponseNamespace="http://www.webserviceX.NET/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public string GetQuote(string symbol) {
+ object[] results = this.Invoke("GetQuote", new object[] {
+ symbol});
+ return ((string)(results[0]));
+ }
+
+ ///
+ public void GetQuoteAsync(string symbol) {
+ this.GetQuoteAsync(symbol, null);
+ }
+
+ ///
+ public void GetQuoteAsync(string symbol, object userState) {
+ if ((this.GetQuoteOperationCompleted == null)) {
+ this.GetQuoteOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetQuoteOperationCompleted);
+ }
+ this.InvokeAsync("GetQuote", new object[] {
+ symbol}, this.GetQuoteOperationCompleted, userState);
+ }
+
+ private void OnGetQuoteOperationCompleted(object arg) {
+ if ((this.GetQuoteCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.GetQuoteCompleted(this, new GetQuoteCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
+ ///
+ public new void CancelAsync(object userState) {
+ base.CancelAsync(userState);
+ }
+
+ private bool IsLocalFileSystemWebService(string url) {
+ if (((url == null)
+ || (url == string.Empty))) {
+ return false;
+ }
+ System.Uri wsUri = new System.Uri(url);
+ if (((wsUri.Port >= 1024)
+ && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")]
+ public delegate void GetQuoteCompletedEventHandler(object sender, GetQuoteCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.17929")]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ public partial class GetQuoteCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+
+ private object[] results;
+
+ internal GetQuoteCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
+ base(exception, cancelled, userState) {
+ this.results = results;
+ }
+
+ ///
+ public string Result {
+ get {
+ this.RaiseExceptionIfNecessary();
+ return ((string)(this.results[0]));
+ }
+ }
+ }
+}
+
+#pragma warning restore 1591
\ No newline at end of file
diff --git a/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/stockquote.wsdl b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/stockquote.wsdl
new file mode 100644
index 00000000..6df1b169
--- /dev/null
+++ b/WpfTraining/02 Data Bindings/05 DataBindingSzenarios/Web References/StockQuoteService/stockquote.wsdl
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Get Stock quote for a company Symbol
+
+
+
+
+
+
+ Get Stock quote for a company Symbol
+
+
+
+
+
+
+ Get Stock quote for a company Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WpfTraining/README.md b/WpfTraining/README.md
index 4f4142fb..8ba15b7b 100644
--- a/WpfTraining/README.md
+++ b/WpfTraining/README.md
@@ -62,4 +62,37 @@ following topics:
I use this sample in WPF trainings to show how to implement XAML concepts like markup
extensions, type converters, content properties, etc. in custom classes.
+# Data Bindings
+
+## Using Dependency Properties
+
+This set of stand-alone XAML pages demonstrate various applications of dependency
+properties like resources, data binding, styling, etc. You can run the XAML pages
+e.g. in Internet Explorer.
+
+## Free Space Watcher
+
+I use this sample in WPF trainings to demonstrate how to implement custom dependency
+properties. `02 FreeSpaceWatcher - Step 1` is a simple implementation while
+`03 FreeSpaceWatcher - Step 2` adds a user control with dependency properties.
+`04 FreeSpaceWatcher - Step 3` finally adds a timer and multiple UI threads in a
+single WPF application.
+
+## Data Binding Scenarios
+
+This sample contains various small examples for data bindings. It covers:
+
+* `ElementName` bindings
+* Binding to XML using XPath
+* Binding to objects in resources
+* `OneWayToSource`
+* Binding to the result of a method using `ObjectDataProvider`
+* Binding to collections
+* Binding to ADO.NET
+* Binding validation
+* Use of `UpdateSourceTrigger`
+* Use of `CompositeCollection`
+* Binding and notification (`INotifyPropertyChanged`, `ObservableCollection`, etc.)
+
+