Browse Source

Add a license description in the header of every .cs and .xaml files.

pull/1645/head
Nebuleux_cp 14 years ago
parent
commit
f0775d4061
  1. 57
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/BusyIndicatorModule.cs
  2. 36
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/NavigationItems/BusyIndicatorNavItem.xaml
  3. 36
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/NavigationItems/BusyIndicatorNavItem.xaml.cs
  4. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Properties/AssemblyInfo.cs
  5. 92
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Resources/Common.xaml
  6. 130
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentTemplateView.xaml
  7. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentTemplateView.xaml.cs
  8. 88
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentView.xaml
  9. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentView.xaml.cs
  10. 120
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorView.xaml
  11. 62
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorView.xaml.cs
  12. 59
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/ButtonModule.cs
  13. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/ButtonSpinnerNavItem.xaml
  14. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/ButtonSpinnerNavItem.xaml.cs
  15. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/DropDownButtonNavItem.xaml
  16. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/DropDownButtonNavItem.xaml.cs
  17. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/SplitButtonNavItem.xaml
  18. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/SplitButtonNavItem.xaml.cs
  19. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Properties/AssemblyInfo.cs
  20. 106
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/ButtonSpinnerView.xaml
  21. 82
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/ButtonSpinnerView.xaml.cs
  22. 100
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/DropDownButtonView.xaml
  23. 59
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/DropDownButtonView.xaml.cs
  24. 99
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/SplitButtonView.xaml
  25. 59
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/SplitButtonView.xaml.cs
  26. 55
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/CalculatorModule.cs
  27. 32
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorNavItem.xaml
  28. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorNavItem.xaml.cs
  29. 32
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorUpDownNavItem.xaml
  30. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorUpDownNavItem.xaml.cs
  31. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Properties/AssemblyInfo.cs
  32. 130
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorUpDownView.xaml
  33. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorUpDownView.xaml.cs
  34. 84
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorView.xaml
  35. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorView.xaml.cs
  36. 49
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/ChildWindowModule.cs
  37. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Properties/AssemblyInfo.cs
  38. 230
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/HomeView.xaml
  39. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/HomeView.xaml.cs
  40. 26
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/NavigationView.xaml
  41. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/NavigationView.xaml.cs
  42. 49
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/ColorModule.cs
  43. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Properties/AssemblyInfo.cs
  44. 75
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/HomeView.xaml
  45. 328
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/HomeView.xaml.cs
  46. 26
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/NavigationView.xaml
  47. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/NavigationView.xaml.cs
  48. 49
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/DateTimeModule.cs
  49. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Properties/AssemblyInfo.cs
  50. 26
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml
  51. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs
  52. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/NavigationView.xaml
  53. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/NavigationView.xaml.cs
  54. 49
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/NumericModule.cs
  55. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Properties/AssemblyInfo.cs
  56. 26
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/HomeView.xaml
  57. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/HomeView.xaml.cs
  58. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/NavigationView.xaml
  59. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/NavigationView.xaml.cs
  60. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Properties/AssemblyInfo.cs
  61. 61
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs
  62. 28
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml
  63. 86
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs
  64. 104
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/BindingToStructs.xaml
  65. 170
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/BindingToStructs.xaml.cs
  66. 145
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml
  67. 372
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs
  68. 60
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml
  69. 186
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs
  70. 54
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml
  71. 260
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs
  72. 60
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml
  73. 141
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs
  74. 129
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml
  75. 38
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs
  76. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml
  77. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml.cs
  78. 76
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml
  79. 264
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml.cs
  80. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Properties/AssemblyInfo.cs
  81. 51
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/TextModule.cs
  82. 35
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/HomeView.xaml
  83. 96
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/HomeView.xaml.cs
  84. 40
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/NavigationView.xaml
  85. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/NavigationView.xaml.cs
  86. 102
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/WatermarkTextBoxView.xaml
  87. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/WatermarkTextBoxView.xaml.cs
  88. 52
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Properties/AssemblyInfo.cs
  89. 50
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml
  90. 39
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml.cs
  91. 30
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/NavigationView.xaml
  92. 46
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/NavigationView.xaml.cs
  93. 51
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/WizardModule.cs
  94. 56
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Commands/TreeViewCommandBehavior.cs
  95. 117
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Commands/TreeViewSelected.cs
  96. 256
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Controls/DemoView.cs
  97. 83
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Converters/CSharpColorConverter.cs
  98. 240
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Converters/XamlColorConverter.cs
  99. 682
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Core/CodeFormatting/CSharpFormat.cs
  100. 663
      ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Core/CodeFormatting/XamlFormat.cs

57
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/BusyIndicatorModule.cs

@ -1,30 +1,47 @@
using System; /************************************************************************
using Samples.Infrastructure;
using Microsoft.Practices.Unity; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.BusyIndicator.NavigationItems; using Samples.Modules.BusyIndicator.NavigationItems;
using Samples.Modules.BusyIndicator.Views; using Samples.Modules.BusyIndicator.Views;
namespace Samples.Modules.BusyIndicator namespace Samples.Modules.BusyIndicator
{ {
public class BusyIndicatorModule : ModuleBase public class BusyIndicatorModule : ModuleBase
{
public BusyIndicatorModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType( typeof( BusyIndicatorView ) );
Container.RegisterNavigationType( typeof( BusyIndicatorCustomContentView ) );
Container.RegisterNavigationType( typeof( BusyIndicatorCustomContentTemplateView ) );
}
protected override void InitializeModule()
{ {
public BusyIndicatorModule(IUnityContainer container, IRegionManager regionManager) RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( BusyIndicatorNavItem ) );
: base(container, regionManager)
{
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(BusyIndicatorView));
Container.RegisterNavigationType(typeof(BusyIndicatorCustomContentView));
Container.RegisterNavigationType(typeof(BusyIndicatorCustomContentTemplateView));
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(BusyIndicatorNavItem));
}
} }
}
} }

36
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/NavigationItems/BusyIndicatorNavItem.xaml

@ -1,14 +1,32 @@
<TreeViewItem x:Class="Samples.Modules.BusyIndicator.NavigationItems.BusyIndicatorNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.BusyIndicator.NavigationItems.BusyIndicatorNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.BusyIndicator.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.BusyIndicator.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.BusyIndicator.Views" xmlns:views="clr-namespace:Samples.Modules.BusyIndicator.Views"
Header="BusyIndicator" Tag="{x:Type views:BusyIndicatorView}"> Header="BusyIndicator" Tag="{x:Type views:BusyIndicatorView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:BusyIndicatorNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:BusyIndicatorNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
<TreeViewItem Header="Custom Content" Tag="{x:Type views:BusyIndicatorCustomContentView}" />
<TreeViewItem Header="Custom Content Template" Tag="{x:Type views:BusyIndicatorCustomContentTemplateView}" />
<TreeViewItem Header="Custom Content" Tag="{x:Type views:BusyIndicatorCustomContentView}" />
<TreeViewItem Header="Custom Content Template" Tag="{x:Type views:BusyIndicatorCustomContentTemplateView}" />
</TreeViewItem> </TreeViewItem>

36
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/NavigationItems/BusyIndicatorNavItem.xaml.cs

@ -1,16 +1,34 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.BusyIndicator.NavigationItems namespace Samples.Modules.BusyIndicator.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for BusyIndicatorNavItem.xaml /// Interaction logic for BusyIndicatorNavItem.xaml
/// </summary> /// </summary>
public partial class BusyIndicatorNavItem : TreeViewItem public partial class BusyIndicatorNavItem : TreeViewItem
{
public BusyIndicatorNavItem()
{ {
public BusyIndicatorNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.BusyIndicator")] [assembly: AssemblyTitle( "Samples.Modules.BusyIndicator" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.BusyIndicator")] [assembly: AssemblyProduct( "Samples.Modules.BusyIndicator" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

92
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Resources/Common.xaml

@ -1,42 +1,60 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"> xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended">
<DataTemplate x:Key="SampleContent" > <DataTemplate x:Key="SampleContent">
<Grid Margin="10" > <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="First Name:" Margin="2" VerticalAlignment="Center" /> <TextBlock Grid.Row="0" Text="First Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="0" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter First Name" /> <extToolkit:WatermarkTextBox Grid.Row="0" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter First Name" />
<TextBlock Grid.Row="1" Text="Last Name:" Margin="2" VerticalAlignment="Center" /> <TextBlock Grid.Row="1" Text="Last Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter Last Name" /> <extToolkit:WatermarkTextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter Last Name" />
<TextBlock Grid.Row="2" Text="Date of Birth:" Margin="2" VerticalAlignment="Center" /> <TextBlock Grid.Row="2" Text="Date of Birth:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DateTimeUpDown Grid.Row="2" Grid.Column="1" Format="ShortDate" Margin="2" VerticalAlignment="Center" Watermark="Enter Date of Birth" /> <extToolkit:DateTimeUpDown Grid.Row="2" Grid.Column="1" Format="ShortDate" Margin="2" VerticalAlignment="Center" Watermark="Enter Date of Birth" />
<TextBlock Grid.Row="3" Text="Salary:" Margin="2" VerticalAlignment="Center" /> <TextBlock Grid.Row="3" Text="Salary:" Margin="2" VerticalAlignment="Center" />
<extToolkit:IntegerUpDown Grid.Row="3" Grid.Column="1" FormatString="C2" Margin="2" VerticalAlignment="Center" Watermark="Enter Salary" /> <extToolkit:IntegerUpDown Grid.Row="3" Grid.Column="1" FormatString="C2" Margin="2" VerticalAlignment="Center" Watermark="Enter Salary" />
<TextBlock Grid.Row="4" Text="Favorite Color:" Margin="2" VerticalAlignment="Center" /> <TextBlock Grid.Row="4" Text="Favorite Color:" Margin="2" VerticalAlignment="Center" />
<extToolkit:ColorPicker Grid.Row="4" Grid.Column="1" Margin="2" VerticalAlignment="Center" /> <extToolkit:ColorPicker Grid.Row="4" Grid.Column="1" Margin="2" VerticalAlignment="Center" />
<StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0"> <StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<Button Width="65" Margin="2">OK</Button> <Button Width="65" Margin="2">OK</Button>
<Button Width="65" Margin="2">Cancel</Button> <Button Width="65" Margin="2">Cancel</Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ResourceDictionary> </ResourceDictionary>

130
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentTemplateView.xaml

@ -1,63 +1,81 @@
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorCustomContentTemplateView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorCustomContentTemplateView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="BusyIndicator"> Title="BusyIndicator">
<infControls:DemoView.Resources> <infControls:DemoView.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" /> <ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</infControls:DemoView.Resources> </infControls:DemoView.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="This example demonstrates how to create a custom content template by setting the BusyContentTemplate property to an instance of a custom DataTemplate. Take notice of how the default ProgressBar is being hidden by setting the PrgressBarStyle property. The default OverlayStyle is also being set to a custom style." <TextBlock Text="This example demonstrates how to create a custom content template by setting the BusyContentTemplate property to an instance of a custom DataTemplate. Take notice of how the default ProgressBar is being hidden by setting the PrgressBarStyle property. The default OverlayStyle is also being set to a custom style."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Grid.Row="2" Text="Custom Content Template:" Style="{StaticResource Header}" /> <TextBlock Grid.Row="2" Text="Custom Content Template:" Style="{StaticResource Header}" />
<extToolkit:BusyIndicator IsBusy="True"> <extToolkit:BusyIndicator IsBusy="True">
<extToolkit:BusyIndicator.BusyContentTemplate> <extToolkit:BusyIndicator.BusyContentTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Margin="4"> <StackPanel Margin="4">
<TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center"/> <TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center" />
<StackPanel Margin="4"> <StackPanel Margin="4">
<TextBlock Text="Downloading message 4/10..."/> <TextBlock Text="Downloading message 4/10..." />
<ProgressBar Value="40" Height="15"/> <ProgressBar Value="40" Height="15" />
</StackPanel> </StackPanel>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Pause" HorizontalAlignment="Right" Margin="0 0 2 0"/> <Button Grid.Column="0" Content="Pause" HorizontalAlignment="Right" Margin="0 0 2 0" />
<Button Grid.Column="1" Content="Cancel" HorizontalAlignment="Left" Margin="2 0 0 0"/> <Button Grid.Column="1" Content="Cancel" HorizontalAlignment="Left" Margin="2 0 0 0" />
</Grid> </Grid>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</extToolkit:BusyIndicator.BusyContentTemplate> </extToolkit:BusyIndicator.BusyContentTemplate>
<extToolkit:BusyIndicator.OverlayStyle> <extToolkit:BusyIndicator.OverlayStyle>
<Style TargetType="Rectangle"> <Style TargetType="Rectangle">
<Setter Property="Fill" Value="#B1EB1D1D"/> <Setter Property="Fill" Value="#B1EB1D1D" />
</Style> </Style>
</extToolkit:BusyIndicator.OverlayStyle> </extToolkit:BusyIndicator.OverlayStyle>
<extToolkit:BusyIndicator.ProgressBarStyle> <extToolkit:BusyIndicator.ProgressBarStyle>
<Style TargetType="ProgressBar"> <Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed" />
</Style> </Style>
</extToolkit:BusyIndicator.ProgressBarStyle> </extToolkit:BusyIndicator.ProgressBarStyle>
<ContentControl ContentTemplate="{StaticResource SampleContent}" /> <ContentControl ContentTemplate="{StaticResource SampleContent}" />
</extToolkit:BusyIndicator> </extToolkit:BusyIndicator>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentTemplateView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.BusyIndicator.Views namespace Samples.Modules.BusyIndicator.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for BusyIndicatorCustomContentTemplateView.xaml /// Interaction logic for BusyIndicatorCustomContentTemplateView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive=false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class BusyIndicatorCustomContentTemplateView : DemoView public partial class BusyIndicatorCustomContentTemplateView : DemoView
{
public BusyIndicatorCustomContentTemplateView()
{ {
public BusyIndicatorCustomContentTemplateView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

88
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentView.xaml

@ -1,41 +1,59 @@
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorCustomContentView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorCustomContentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="BusyIndicator"> Title="BusyIndicator">
<infControls:DemoView.Resources> <infControls:DemoView.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" /> <ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</infControls:DemoView.Resources> </infControls:DemoView.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="This example demonstrates how to define your own custom content. This is done by setting the BusyContent property." <TextBlock Text="This example demonstrates how to define your own custom content. This is done by setting the BusyContent property."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Custom Content:" Style="{StaticResource Header}" /> <TextBlock Text="Custom Content:" Style="{StaticResource Header}" />
<extToolkit:BusyIndicator IsBusy="True"> <extToolkit:BusyIndicator IsBusy="True">
<extToolkit:BusyIndicator.BusyContent> <extToolkit:BusyIndicator.BusyContent>
<StackPanel Orientation="Horizontal" > <StackPanel Orientation="Horizontal">
<Image Source="/Samples.Modules.BusyIndicator;component/Images/CdBurning32.png" /> <Image Source="/Samples.Modules.BusyIndicator;component/Images/CdBurning32.png" />
<StackPanel Margin="5,0"> <StackPanel Margin="5,0">
<TextBlock Text="Burning CD..." VerticalAlignment="Center" /> <TextBlock Text="Burning CD..." VerticalAlignment="Center" />
<TextBlock Text="Madonna - Like a Virgin" VerticalAlignment="Center" Margin="8,0" /> <TextBlock Text="Madonna - Like a Virgin" VerticalAlignment="Center" Margin="8,0" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</extToolkit:BusyIndicator.BusyContent> </extToolkit:BusyIndicator.BusyContent>
<ContentControl ContentTemplate="{StaticResource SampleContent}" /> <ContentControl ContentTemplate="{StaticResource SampleContent}" />
</extToolkit:BusyIndicator> </extToolkit:BusyIndicator>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorCustomContentView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.BusyIndicator.Views namespace Samples.Modules.BusyIndicator.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for BusyIndicatorCustomContentView.xaml /// Interaction logic for BusyIndicatorCustomContentView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive=false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class BusyIndicatorCustomContentView : DemoView public partial class BusyIndicatorCustomContentView : DemoView
{
public BusyIndicatorCustomContentView()
{ {
public BusyIndicatorCustomContentView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

120
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorView.xaml

@ -1,4 +1,22 @@
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.BusyIndicator.Views.BusyIndicatorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Samples.Modules.BusyIndicator.Views" xmlns:local="clr-namespace:Samples.Modules.BusyIndicator.Views"
@ -6,54 +24,54 @@
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="BusyIndicator"> Title="BusyIndicator">
<infControls:DemoView.Resources> <infControls:DemoView.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" /> <ResourceDictionary Source="/Samples.Modules.Busyindicator;component/Resources/Common.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<local:IntegerToTimespanConverter x:Key="TimeSpanConverter" /> <local:IntegerToTimespanConverter x:Key="TimeSpanConverter" />
</ResourceDictionary> </ResourceDictionary>
</infControls:DemoView.Resources> </infControls:DemoView.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="BusyIndicator makes it easy to let the user know when an application is busy. Simply wrap the relevant content in an instance of the BusyIndicator control and toggle its IsBusy property to True during any long-running process." <TextBlock Text="BusyIndicator makes it easy to let the user know when an application is busy. Simply wrap the relevant content in an instance of the BusyIndicator control and toggle its IsBusy property to True during any long-running process."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="IsBusy:" VerticalAlignment="Center" Margin="2"/> <TextBlock Text="IsBusy:" VerticalAlignment="Center" Margin="2" />
<CheckBox x:Name="_isBusy" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="When true shows the BusyIndicator" /> <CheckBox x:Name="_isBusy" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="When true shows the BusyIndicator" />
<TextBlock Text="DisplayAfter:" Grid.Row="1" VerticalAlignment="Center" Margin="2"/> <TextBlock Text="DisplayAfter:" Grid.Row="1" VerticalAlignment="Center" Margin="2" />
<StackPanel Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Left" Orientation="Horizontal">
<extToolkit:IntegerUpDown x:Name="_displayAfter" Width="65" VerticalAlignment="Center" Minimum="0" Increment="100" Value="0" ToolTip="Sets the TimeSpan to wait until the BusyIndicator is displayed." /> <extToolkit:IntegerUpDown x:Name="_displayAfter" Width="65" VerticalAlignment="Center" Minimum="0" Increment="100" Value="0" ToolTip="Sets the TimeSpan to wait until the BusyIndicator is displayed." />
<TextBlock Text="milliseconds" Margin="5,0" VerticalAlignment="Center"/> <TextBlock Text="milliseconds" Margin="5,0" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<extToolkit:BusyIndicator IsBusy="{Binding IsChecked, ElementName=_isBusy}" DisplayAfter="{Binding Value, ElementName=_displayAfter, Converter={StaticResource TimeSpanConverter}}" > <extToolkit:BusyIndicator IsBusy="{Binding IsChecked, ElementName=_isBusy}" DisplayAfter="{Binding Value, ElementName=_displayAfter, Converter={StaticResource TimeSpanConverter}}">
<ContentControl ContentTemplate="{StaticResource SampleContent}" /> <ContentControl ContentTemplate="{StaticResource SampleContent}" />
</extToolkit:BusyIndicator> </extToolkit:BusyIndicator>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

62
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.BusyIndicator/Views/BusyIndicatorView.xaml.cs

@ -1,32 +1,50 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
using Microsoft.Practices.Prism.Regions; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Windows.Data; using System.Windows.Data;
using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.BusyIndicator.Views namespace Samples.Modules.BusyIndicator.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive=false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class BusyIndicatorView : DemoView public partial class BusyIndicatorView : DemoView
{
public BusyIndicatorView()
{
InitializeComponent();
}
}
public class IntegerToTimespanConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{ {
public BusyIndicatorView() return TimeSpan.FromMilliseconds( ( int )value );
{
InitializeComponent();
}
} }
public class IntegerToTimespanConverter : IValueConverter public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{ {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) throw new NotImplementedException();
{
return TimeSpan.FromMilliseconds((int)value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
} }
}
} }

59
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/ButtonModule.cs

@ -1,30 +1,49 @@
using System; /************************************************************************
using Samples.Infrastructure;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity; using Microsoft.Practices.Unity;
using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.Button.Views;
using Samples.Modules.Button.NavigationItems; using Samples.Modules.Button.NavigationItems;
using Samples.Modules.Button.Views;
namespace Samples.Modules.Button namespace Samples.Modules.Button
{ {
public class ButtonModule : ModuleBase public class ButtonModule : ModuleBase
{
public ButtonModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( ButtonSpinnerNavItem ) );
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( DropDownButtonNavItem ) );
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( SplitButtonNavItem ) );
}
protected override void RegisterViewsAndTypes()
{ {
public ButtonModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( ButtonSpinnerView ) );
: base(container, regionManager) { } Container.RegisterNavigationType( typeof( DropDownButtonView ) );
Container.RegisterNavigationType( typeof( SplitButtonView ) );
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(ButtonSpinnerNavItem));
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(DropDownButtonNavItem));
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(SplitButtonNavItem));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(ButtonSpinnerView));
Container.RegisterNavigationType(typeof(DropDownButtonView));
Container.RegisterNavigationType(typeof(SplitButtonView));
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/ButtonSpinnerNavItem.xaml

@ -1,12 +1,30 @@
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.ButtonSpinnerNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.ButtonSpinnerNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.Button.Views" xmlns:views="clr-namespace:Samples.Modules.Button.Views"
Header="ButtonSpinner" Tag="{x:Type views:ButtonSpinnerView}" > Header="ButtonSpinner" Tag="{x:Type views:ButtonSpinnerView}" >
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:ButtonSpinnerNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:ButtonSpinnerNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/ButtonSpinnerNavItem.xaml.cs

@ -1,16 +1,33 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.Button.NavigationItems namespace Samples.Modules.Button.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for ButtonSpinnerNavItem.xaml /// Interaction logic for ButtonSpinnerNavItem.xaml
/// </summary> /// </summary>
public partial class ButtonSpinnerNavItem : TreeViewItem public partial class ButtonSpinnerNavItem : TreeViewItem
{
public ButtonSpinnerNavItem()
{ {
public ButtonSpinnerNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/DropDownButtonNavItem.xaml

@ -1,12 +1,30 @@
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.DropDownButtonNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.DropDownButtonNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.Button.Views" xmlns:views="clr-namespace:Samples.Modules.Button.Views"
Header="DropDownButton" Tag="{x:Type views:DropDownButtonView}"> Header="DropDownButton" Tag="{x:Type views:DropDownButtonView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:DropDownButtonNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:DropDownButtonNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/DropDownButtonNavItem.xaml.cs

@ -1,16 +1,33 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.Button.NavigationItems namespace Samples.Modules.Button.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for DropDownButtonNavItem.xaml /// Interaction logic for DropDownButtonNavItem.xaml
/// </summary> /// </summary>
public partial class DropDownButtonNavItem : TreeViewItem public partial class DropDownButtonNavItem : TreeViewItem
{
public DropDownButtonNavItem()
{ {
public DropDownButtonNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/SplitButtonNavItem.xaml

@ -1,12 +1,30 @@
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.SplitButtonNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Button.NavigationItems.SplitButtonNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.Button.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.Button.Views" xmlns:views="clr-namespace:Samples.Modules.Button.Views"
Header="SplitButton" Tag="{x:Type views:SplitButtonView}"> Header="SplitButton" Tag="{x:Type views:SplitButtonView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:SplitButtonNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:SplitButtonNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/NavigationItems/SplitButtonNavItem.xaml.cs

@ -1,16 +1,33 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.Button.NavigationItems namespace Samples.Modules.Button.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for SplitButtonNavItem.xaml /// Interaction logic for SplitButtonNavItem.xaml
/// </summary> /// </summary>
public partial class SplitButtonNavItem : TreeViewItem public partial class SplitButtonNavItem : TreeViewItem
{
public SplitButtonNavItem()
{ {
public SplitButtonNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Button")] [assembly: AssemblyTitle( "Samples.Modules.Button" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.Button")] [assembly: AssemblyProduct( "Samples.Modules.Button" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

106
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/ButtonSpinnerView.xaml

@ -1,49 +1,69 @@
<infControls:DemoView x:Class="Samples.Modules.Button.Views.ButtonSpinnerView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Button.Views.ButtonSpinnerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="ButtonSpinner"> Title="ButtonSpinner">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The ButtonSpinner control allows you to add button spinners to any element and then respond to the Spin event to manipulate that element. The Spin event lets the developer know which direction the buttons are spinning; SpinDirection.Increase indicates an increment, SpinDirection.Decrease indicates a decrement." <TextBlock Text="The ButtonSpinner control allows you to add button spinners to any element and then respond to the Spin event to manipulate that element. The Spin event lets the developer know which direction the buttons are spinning; SpinDirection.Increase indicates an increment, SpinDirection.Decrease indicates a decrement."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="AllowSpin:" VerticalAlignment="Center" /> <TextBlock Text="AllowSpin:" VerticalAlignment="Center" />
<CheckBox x:Name="_allowSpin" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="When true allows the ButtonSpinner to perform increment/decrement operations."/> <CheckBox x:Name="_allowSpin" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="When true allows the ButtonSpinner to perform increment/decrement operations." />
<TextBlock Text="ShowButtonSpinner:" VerticalAlignment="Center" Grid.Row="1" /> <TextBlock Text="ShowButtonSpinner:" VerticalAlignment="Center" Grid.Row="1" />
<CheckBox x:Name="_showButtonSpinner" Grid.Row="1" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Gets/Sets the visibility of the button spinners."/> <CheckBox x:Name="_showButtonSpinner" Grid.Row="1" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Gets/Sets the visibility of the button spinners." />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<TextBlock Text="You can wrap any element by placing it inside the content area of the ButtonSpinner control. As an example, lets create our own simple numeric up/down control" <TextBlock Text="You can wrap any element by placing it inside the content area of the ButtonSpinner control. As an example, lets create our own simple numeric up/down control"
TextWrapping="Wrap"/> TextWrapping="Wrap" />
<extToolkit:ButtonSpinner Margin="10" Width="150" HorizontalAlignment="Left" <extToolkit:ButtonSpinner Margin="10"
AllowSpin="{Binding IsChecked, ElementName=_allowSpin}" Width="150"
ShowButtonSpinner="{Binding IsChecked, ElementName=_showButtonSpinner}" HorizontalAlignment="Left"
Spin="ButtonSpinner_Spin" > AllowSpin="{Binding IsChecked, ElementName=_allowSpin}"
<TextBox Text="0" BorderThickness="0" HorizontalContentAlignment="Right" /> ShowButtonSpinner="{Binding IsChecked, ElementName=_showButtonSpinner}"
</extToolkit:ButtonSpinner> Spin="ButtonSpinner_Spin">
</StackPanel> <TextBox Text="0" BorderThickness="0" HorizontalContentAlignment="Right" />
</Grid> </extToolkit:ButtonSpinner>
</StackPanel>
</Grid>
</infControls:DemoView> </infControls:DemoView>

82
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/ButtonSpinnerView.xaml.cs

@ -1,40 +1,58 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Windows.Controls;
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Windows.Controls; using Microsoft.Windows.Controls;
using System.Windows.Controls; using Samples.Infrastructure.Controls;
namespace Samples.Modules.Button.Views namespace Samples.Modules.Button.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for ButtonSpinnerView.xaml /// Interaction logic for ButtonSpinnerView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class ButtonSpinnerView : DemoView public partial class ButtonSpinnerView : DemoView
{
public ButtonSpinnerView()
{ {
public ButtonSpinnerView() InitializeComponent();
{ }
InitializeComponent();
} private void ButtonSpinner_Spin( object sender, Microsoft.Windows.Controls.SpinEventArgs e )
{
private void ButtonSpinner_Spin(object sender, Microsoft.Windows.Controls.SpinEventArgs e) ButtonSpinner spinner = ( ButtonSpinner )sender;
{ TextBox txtBox = ( TextBox )spinner.Content;
ButtonSpinner spinner = (ButtonSpinner)sender;
TextBox txtBox = (TextBox)spinner.Content; try
{
try int value = String.IsNullOrEmpty( txtBox.Text ) ? 0 : Convert.ToInt32( txtBox.Text );
{ if( e.Direction == Microsoft.Windows.Controls.SpinDirection.Increase )
int value = String.IsNullOrEmpty(txtBox.Text) ? 0 : Convert.ToInt32(txtBox.Text); value++;
if (e.Direction == Microsoft.Windows.Controls.SpinDirection.Increase) else
value++; value--;
else txtBox.Text = value.ToString();
value--; }
txtBox.Text = value.ToString(); catch
} {
catch txtBox.Text = "0";
{ }
txtBox.Text = "0";
}
}
} }
}
} }

100
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/DropDownButtonView.xaml

@ -1,46 +1,64 @@
<infControls:DemoView x:Class="Samples.Modules.Button.Views.DropDownButtonView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Button.Views.DropDownButtonView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="DropDownButton" > Title="DropDownButton">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The DropDownButton control is a button that when clicked displays a drop down in which you can place any custom content within." <TextBlock Text="The DropDownButton control is a button that when clicked displays a drop down in which you can place any custom content within."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="IsOpen: " VerticalAlignment="Center" /> <TextBlock Text="IsOpen: " VerticalAlignment="Center" />
<CheckBox x:Name="_isOpen" Grid.Column="1" IsChecked="False" VerticalAlignment="Center" Margin="5" ClickMode="Press" ToolTip="Get/Sets a value indicating whether or not the drop down is open." /> <CheckBox x:Name="_isOpen" Grid.Column="1" IsChecked="False" VerticalAlignment="Center" Margin="5" ClickMode="Press" ToolTip="Get/Sets a value indicating whether or not the drop down is open." />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<extToolkit:DropDownButton x:Name="_dropDownButton" Margin="10" Width="150" HorizontalAlignment="Left" Content="Click Me" IsOpen="{Binding IsChecked, ElementName=_isOpen, Mode=TwoWay}" <extToolkit:DropDownButton x:Name="_dropDownButton" Margin="10" Width="150" HorizontalAlignment="Left" Content="Click Me" IsOpen="{Binding IsChecked, ElementName=_isOpen, Mode=TwoWay}"
Click="DropDownButton_Click"> Click="DropDownButton_Click">
<extToolkit:DropDownButton.DropDownContent> <extToolkit:DropDownButton.DropDownContent>
<StackPanel> <StackPanel>
<extToolkit:ColorCanvas /> <extToolkit:ColorCanvas />
<Button Click="Button_Click" Margin="10">OK</Button> <Button Click="Button_Click" Margin="10">OK</Button>
</StackPanel> </StackPanel>
</extToolkit:DropDownButton.DropDownContent> </extToolkit:DropDownButton.DropDownContent>
</extToolkit:DropDownButton> </extToolkit:DropDownButton>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

59
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/DropDownButtonView.xaml.cs

@ -1,28 +1,45 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Button.Views namespace Samples.Modules.Button.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for DropDownButtonView.xaml /// Interaction logic for DropDownButtonView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class DropDownButtonView : DemoView public partial class DropDownButtonView : DemoView
{
public DropDownButtonView()
{
InitializeComponent();
}
private void DropDownButton_Click( object sender, System.Windows.RoutedEventArgs e )
{
}
private void Button_Click( object sender, System.Windows.RoutedEventArgs e )
{ {
public DropDownButtonView() _dropDownButton.IsOpen = false;
{
InitializeComponent();
}
private void DropDownButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
_dropDownButton.IsOpen = false;
}
} }
}
} }

99
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/SplitButtonView.xaml

@ -1,47 +1,64 @@
<infControls:DemoView x:Class="Samples.Modules.Button.Views.SplitButtonView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Button.Views.SplitButtonView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="SplitButton"> Title="SplitButton">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The SplitButton control is a button that can be clicked and also provides a drop down in which you can place any custom content within." <TextBlock Text="The SplitButton control is a button that can be clicked and also provides a drop down in which you can place any custom content within."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="IsOpen: " VerticalAlignment="Center" /> <TextBlock Text="IsOpen: " VerticalAlignment="Center" />
<CheckBox x:Name="_isOpen" Grid.Column="1" IsChecked="False" VerticalAlignment="Center" Margin="5" ClickMode="Press" ToolTip="Get/Sets a value indicating whether or not the drop down is open."/> <CheckBox x:Name="_isOpen" Grid.Column="1" IsChecked="False" VerticalAlignment="Center" Margin="5" ClickMode="Press" ToolTip="Get/Sets a value indicating whether or not the drop down is open." />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<extToolkit:SplitButton x:Name="_splitButton" Margin="10" Width="150" HorizontalAlignment="Left" Content="Click Me" IsOpen="{Binding IsChecked, ElementName=_isOpen, Mode=TwoWay}" <extToolkit:SplitButton x:Name="_splitButton" Margin="10" Width="150" HorizontalAlignment="Left" Content="Click Me" IsOpen="{Binding IsChecked, ElementName=_isOpen, Mode=TwoWay}"
Click="SplitButton_Click"> Click="SplitButton_Click">
<extToolkit:SplitButton.DropDownContent> <extToolkit:SplitButton.DropDownContent>
<StackPanel> <StackPanel>
<extToolkit:ColorCanvas /> <extToolkit:ColorCanvas />
<Button Click="Button_Click" Margin="10">OK</Button> <Button Click="Button_Click" Margin="10">OK</Button>
</StackPanel> </StackPanel>
</extToolkit:SplitButton.DropDownContent> </extToolkit:SplitButton.DropDownContent>
</extToolkit:SplitButton> </extToolkit:SplitButton>
</StackPanel>
</StackPanel> </Grid>
</Grid>
</infControls:DemoView> </infControls:DemoView>

59
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/SplitButtonView.xaml.cs

@ -1,28 +1,45 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Button.Views namespace Samples.Modules.Button.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for SplitButtonView.xaml /// Interaction logic for SplitButtonView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class SplitButtonView : DemoView public partial class SplitButtonView : DemoView
{
public SplitButtonView()
{
InitializeComponent();
}
private void SplitButton_Click( object sender, System.Windows.RoutedEventArgs e )
{
Microsoft.Windows.Controls.MessageBox.Show( "Thanks for clicking me!", "SplitButton Click" );
}
private void Button_Click( object sender, System.Windows.RoutedEventArgs e )
{ {
public SplitButtonView() _splitButton.IsOpen = false;
{
InitializeComponent();
}
private void SplitButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
Microsoft.Windows.Controls.MessageBox.Show("Thanks for clicking me!", "SplitButton Click");
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
_splitButton.IsOpen = false;
}
} }
}
} }

55
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/CalculatorModule.cs

@ -1,28 +1,47 @@
using System; /************************************************************************
using Samples.Infrastructure;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity; using Microsoft.Practices.Unity;
using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.Calculator.Views;
using Samples.Modules.Calculator.NavigationItems; using Samples.Modules.Calculator.NavigationItems;
using Samples.Modules.Calculator.Views;
namespace Samples.Modules.Calculator namespace Samples.Modules.Calculator
{ {
public class CalculatorModule : ModuleBase public class CalculatorModule : ModuleBase
{
public CalculatorModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( CalculatorNavItem ) );
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( CalculatorUpDownNavItem ) );
}
protected override void RegisterViewsAndTypes()
{ {
public CalculatorModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( CalculatorView ) );
: base(container, regionManager) { } Container.RegisterNavigationType( typeof( CalculatorUpDownView ) );
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(CalculatorNavItem));
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(CalculatorUpDownNavItem));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(CalculatorView));
Container.RegisterNavigationType(typeof(CalculatorUpDownView));
}
} }
}
} }

32
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorNavItem.xaml

@ -1,12 +1,30 @@
<TreeViewItem x:Class="Samples.Modules.Calculator.NavigationItems.CalculatorNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Calculator.NavigationItems.CalculatorNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.Calculator.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.Calculator.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.Calculator.Views" xmlns:views="clr-namespace:Samples.Modules.Calculator.Views"
Header="Calculator" Tag="{x:Type views:CalculatorView}" > Header="Calculator" Tag="{x:Type views:CalculatorView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:CalculatorNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:CalculatorNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorNavItem.xaml.cs

@ -1,16 +1,33 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.Calculator.NavigationItems namespace Samples.Modules.Calculator.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for CalculatorNavItem.xaml /// Interaction logic for CalculatorNavItem.xaml
/// </summary> /// </summary>
public partial class CalculatorNavItem : TreeViewItem public partial class CalculatorNavItem : TreeViewItem
{
public CalculatorNavItem()
{ {
public CalculatorNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

32
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorUpDownNavItem.xaml

@ -1,12 +1,30 @@
<TreeViewItem x:Class="Samples.Modules.Calculator.NavigationItems.CalculatorUpDownNavItem" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Calculator.NavigationItems.CalculatorUpDownNavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navItems="clr-namespace:Samples.Modules.Calculator.NavigationItems" xmlns:navItems="clr-namespace:Samples.Modules.Calculator.NavigationItems"
xmlns:views="clr-namespace:Samples.Modules.Calculator.Views" xmlns:views="clr-namespace:Samples.Modules.Calculator.Views"
Header="CalculatorUpDown" Tag="{x:Type views:CalculatorUpDownView}" > Header="CalculatorUpDown" Tag="{x:Type views:CalculatorUpDownView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="navItems:CalculatorUpDownNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="navItems:CalculatorUpDownNavItem" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/NavigationItems/CalculatorUpDownNavItem.xaml.cs

@ -1,16 +1,33 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; using System.Windows.Controls;
namespace Samples.Modules.Calculator.NavigationItems namespace Samples.Modules.Calculator.NavigationItems
{ {
/// <summary> /// <summary>
/// Interaction logic for CalculatorUpDownNavItem.xaml /// Interaction logic for CalculatorUpDownNavItem.xaml
/// </summary> /// </summary>
public partial class CalculatorUpDownNavItem : TreeViewItem public partial class CalculatorUpDownNavItem : TreeViewItem
{
public CalculatorUpDownNavItem()
{ {
public CalculatorUpDownNavItem() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Caclulator")] [assembly: AssemblyTitle( "Samples.Modules.Caclulator" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.Caclulator")] [assembly: AssemblyProduct( "Samples.Modules.Caclulator" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

130
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorUpDownView.xaml

@ -1,62 +1,80 @@
<infControls:DemoView x:Class="Samples.Modules.Calculator.Views.CalculatorUpDownView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Calculator.Views.CalculatorUpDownView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="CalculatorUpDown"> Title="CalculatorUpDown">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The CalculatorUpDown provides a TextBox with button spinners that allow incrementing and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel. It also provides a Calculator dropdown which allows you to perform mathematical calculations." <TextBlock Text="The CalculatorUpDown provides a TextBox with button spinners that allow incrementing and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel. It also provides a Calculator dropdown which allows you to perform mathematical calculations."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5" HorizontalAlignment="Left"> <Grid Margin="5" HorizontalAlignment="Left">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="Precision: " VerticalAlignment="Center" /> <TextBlock Text="Precision: " VerticalAlignment="Center" />
<extToolkit:IntegerUpDown x:Name="_precision" Grid.Column="1" Width="75" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Minimum="0" Value="2" ToolTip="Gets/Sets the maximum number of digits displayed to the right of the decimal point." /> <extToolkit:IntegerUpDown x:Name="_precision" Grid.Column="1" Width="75" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Minimum="0" Value="2" ToolTip="Gets/Sets the maximum number of digits displayed to the right of the decimal point." />
<TextBlock Text="FormatString:" Grid.Row="1" VerticalAlignment="Center"/> <TextBlock Text="FormatString:" Grid.Row="1" VerticalAlignment="Center" />
<ComboBox x:Name="_formatString" SelectedIndex="0" Grid.Row="1" Grid.Column="1" Width="150" Margin="5"> <ComboBox x:Name="_formatString" SelectedIndex="0" Grid.Row="1" Grid.Column="1" Width="150" Margin="5">
<ComboBoxItem Tag="C2">Currency</ComboBoxItem> <ComboBoxItem Tag="C2">Currency</ComboBoxItem>
<ComboBoxItem Tag="F2">Fixed Point</ComboBoxItem> <ComboBoxItem Tag="F2">Fixed Point</ComboBoxItem>
<ComboBoxItem Tag="G">General</ComboBoxItem> <ComboBoxItem Tag="G">General</ComboBoxItem>
<ComboBoxItem Tag="N">Number</ComboBoxItem> <ComboBoxItem Tag="N">Number</ComboBoxItem>
<ComboBoxItem Tag="P2">Percent</ComboBoxItem> <ComboBoxItem Tag="P2">Percent</ComboBoxItem>
</ComboBox> </ComboBox>
<TextBlock Text="Watermakr:" Grid.Row="2" VerticalAlignment="Center"/> <TextBlock Text="Watermakr:" Grid.Row="2" VerticalAlignment="Center" />
<TextBox x:Name="_watermark" Grid.Row="2" Grid.Column="1" Width="150" Margin="5" Text="Enter Value"/> <TextBox x:Name="_watermark" Grid.Row="2" Grid.Column="1" Width="150" Margin="5" Text="Enter Value" />
<TextBlock Grid.Column="2" Text="Increment" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Text="Increment" VerticalAlignment="Center" />
<TextBlock Grid.Column="2" Grid.Row="1" Text="Minimum" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Grid.Row="1" Text="Minimum" VerticalAlignment="Center" />
<TextBlock Grid.Column="2" Grid.Row="2" Text="Maximum" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Grid.Row="2" Text="Maximum" VerticalAlignment="Center" />
<extToolkit:IntegerUpDown Grid.Column="3" Name="_increment" Minimum="0" Value="1" VerticalAlignment="Center" Margin="5" Width="150" /> <extToolkit:IntegerUpDown Grid.Column="3" Name="_increment" Minimum="0" Value="1" VerticalAlignment="Center" Margin="5" Width="150" />
<extToolkit:IntegerUpDown Grid.Column="3" Grid.Row="1" Name="_minimum" Value="-100" VerticalAlignment="Center" Margin="5" Width="150" /> <extToolkit:IntegerUpDown Grid.Column="3" Grid.Row="1" Name="_minimum" Value="-100" VerticalAlignment="Center" Margin="5" Width="150" />
<extToolkit:IntegerUpDown Grid.Column="3" Grid.Row="2" Name="_maximum" Value="5000" VerticalAlignment="Center" Margin="5" Width="150" /> <extToolkit:IntegerUpDown Grid.Column="3" Grid.Row="2" Name="_maximum" Value="5000" VerticalAlignment="Center" Margin="5" Width="150" />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10" HorizontalAlignment="Left"> <StackPanel Grid.Row="2" Margin="10" HorizontalAlignment="Left">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<extToolkit:CalculatorUpDown Margin="10" Width="250" <extToolkit:CalculatorUpDown Margin="10" Width="250"
Increment="{Binding Value, ElementName=_increment}" Increment="{Binding Value, ElementName=_increment}"
Maximum="{Binding Value, ElementName=_maximum}" Maximum="{Binding Value, ElementName=_maximum}"
Minimum="{Binding Value, ElementName=_minimum}" Minimum="{Binding Value, ElementName=_minimum}"
Precision="{Binding Value, ElementName=_precision}" Precision="{Binding Value, ElementName=_precision}"
FormatString="{Binding SelectedItem.Tag, ElementName=_formatString}" FormatString="{Binding SelectedItem.Tag, ElementName=_formatString}"
Watermark="{Binding Text, ElementName=_watermark}"/> Watermark="{Binding Text, ElementName=_watermark}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorUpDownView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Calculator.Views namespace Samples.Modules.Calculator.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for CalculatorUpDownView.xaml /// Interaction logic for CalculatorUpDownView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class CalculatorUpDownView : DemoView public partial class CalculatorUpDownView : DemoView
{
public CalculatorUpDownView()
{ {
public CalculatorUpDownView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

84
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorView.xaml

@ -1,39 +1,57 @@
<infControls:DemoView x:Class="Samples.Modules.Calculator.Views.CalculatorView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Calculator.Views.CalculatorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Calculator"> Title="Calculator">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The Calculator is a control used for performing mathematical calculations." <TextBlock Text="The Calculator is a control used for performing mathematical calculations."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="Precision: " VerticalAlignment="Center" /> <TextBlock Text="Precision: " VerticalAlignment="Center" />
<extToolkit:IntegerUpDown x:Name="_precision" Grid.Column="1" Width="75" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Minimum="0" Value="2" ToolTip="Gets/Sets the maximum number of digits displayed to the right of the decimal point." /> <extToolkit:IntegerUpDown x:Name="_precision" Grid.Column="1" Width="75" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5" Minimum="0" Value="2" ToolTip="Gets/Sets the maximum number of digits displayed to the right of the decimal point." />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<TextBlock Text="When the Calculator has focus, you can use the keyboard to interact with the key pad. Click the Calculator to give focus." Margin="10,0"/> <TextBlock Text="When the Calculator has focus, you can use the keyboard to interact with the key pad. Click the Calculator to give focus." Margin="10,0" />
<extToolkit:Calculator Margin="10" Width="250" Precision="{Binding Value, ElementName=_precision}" /> <extToolkit:Calculator Margin="10" Width="250" Precision="{Binding Value, ElementName=_precision}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Caclulator/Views/CalculatorView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Calculator.Views namespace Samples.Modules.Calculator.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for CalculatorView.xaml /// Interaction logic for CalculatorView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class CalculatorView : DemoView public partial class CalculatorView : DemoView
{
public CalculatorView()
{ {
public CalculatorView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

49
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/ChildWindowModule.cs

@ -1,25 +1,44 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.ChildWindow.Views; using Samples.Modules.ChildWindow.Views;
namespace Samples.Modules.ChildWindow namespace Samples.Modules.ChildWindow
{ {
public class ChildWindowModule: ModuleBase public class ChildWindowModule : ModuleBase
{
public ChildWindowModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public ChildWindowModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.ChildWindow")] [assembly: AssemblyTitle( "Samples.Modules.ChildWindow" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.ChildWindow")] [assembly: AssemblyProduct( "Samples.Modules.ChildWindow" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

230
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/HomeView.xaml

@ -1,115 +1,133 @@
<infControls:DemoView x:Class="Samples.Modules.ChildWindow.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.ChildWindow.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="ChildWindow"> Title="ChildWindow">
<infControls:DemoView.Resources>
<ObjectDataProvider x:Key="WindowStates" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}" >
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="extToolkit:WindowState"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="WindowStartupLocations" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}" >
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="extToolkit:WindowStartupLocation"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</infControls:DemoView.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="ChildWindow description goes here."
TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5" >
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Caption:" Margin="2" VerticalAlignment="Center" />
<TextBox Name="_txtCaption" Grid.Column="1" Margin="5" Text="ChildWindow" VerticalAlignment="Center" />
<TextBlock Grid.Row="1" Name="textBlock2" Text="Left:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DoubleUpDown x:Name="_txtLeft" Grid.Column="1" Grid.Row="1" Value="0" VerticalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="2" Name="textBlock3" Text="Top:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DoubleUpDown x:Name="_txtTop" Grid.Column="1" Grid.Row="2" Value="0" VerticalAlignment="Center" Margin="5" />
<TextBlock Text="IsModal:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<CheckBox x:Name="_chkIsModal" Grid.Column="3" VerticalAlignment="Center" Margin="5" IsChecked="True" />
<TextBlock Grid.Row="1" Text="WindowState:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<ComboBox Grid.Column="3" Grid.Row="1" Name="_cboWindowState" ItemsSource="{Binding Source={StaticResource WindowStates}}" SelectedIndex="1" VerticalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="2" Text="WindowStartupLocation:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<ComboBox Grid.Column="3" Grid.Row="2" Name="_cboWindowStartupLocations" ItemsSource="{Binding Source={StaticResource WindowStartupLocations}}" SelectedIndex="0" VerticalAlignment="Center" Margin="5" />
<infControls:DemoView.Resources>
<ObjectDataProvider x:Key="WindowStates" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="extToolkit:WindowState" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="WindowStartupLocations" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="extToolkit:WindowStartupLocation" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</infControls:DemoView.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="ChildWindow description goes here."
TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Caption:" Margin="2" VerticalAlignment="Center" />
<TextBox Name="_txtCaption" Grid.Column="1" Margin="5" Text="ChildWindow" VerticalAlignment="Center" />
<TextBlock Grid.Row="1" Name="textBlock2" Text="Left:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DoubleUpDown x:Name="_txtLeft" Grid.Column="1" Grid.Row="1" Value="0" VerticalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="2" Name="textBlock3" Text="Top:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DoubleUpDown x:Name="_txtTop" Grid.Column="1" Grid.Row="2" Value="0" VerticalAlignment="Center" Margin="5" />
<TextBlock Text="IsModal:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<CheckBox x:Name="_chkIsModal" Grid.Column="3" VerticalAlignment="Center" Margin="5" IsChecked="True" />
<TextBlock Grid.Row="1" Text="WindowState:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<ComboBox Grid.Column="3" Grid.Row="1" Name="_cboWindowState" ItemsSource="{Binding Source={StaticResource WindowStates}}" SelectedIndex="1" VerticalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="2" Text="WindowStartupLocation:" VerticalAlignment="Center" Margin="2" Grid.Column="2" />
<ComboBox Grid.Column="3" Grid.Row="2" Name="_cboWindowStartupLocations" ItemsSource="{Binding Source={StaticResource WindowStartupLocations}}" SelectedIndex="0" VerticalAlignment="Center" Margin="5" />
</Grid>
</GroupBox>
<Grid Grid.Row="2" Margin="10">
<extToolkit:ChildWindow Width="350"
Caption="{Binding Text, ElementName=_txtCaption}"
IsModal="{Binding IsChecked, ElementName=_chkIsModal}"
Left="{Binding Value, ElementName=_txtLeft, Mode=TwoWay}"
Top="{Binding Value, ElementName=_txtTop, Mode=TwoWay}"
WindowStartupLocation="{Binding SelectedItem, ElementName=_cboWindowStartupLocations}"
WindowState="{Binding SelectedItem, ElementName=_cboWindowState}">
<Grid Margin="10" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="First Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="0" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter First Name" />
<TextBlock Grid.Row="1" Text="Last Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter Last Name" />
<TextBlock Grid.Row="2" Text="Date of Birth:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DateTimeUpDown Grid.Row="2" Grid.Column="1" Format="ShortDate" Margin="2" VerticalAlignment="Center" Watermark="Enter Date of Birth" />
<TextBlock Grid.Row="3" Text="Salary:" Margin="2" VerticalAlignment="Center" />
<extToolkit:IntegerUpDown Grid.Row="3" Grid.Column="1" FormatString="C2" Margin="2" VerticalAlignment="Center" Watermark="Enter Salary" />
<TextBlock Grid.Row="4" Text="Favorite Color:" Margin="2" VerticalAlignment="Center" />
<extToolkit:ColorPicker Grid.Row="4" Grid.Column="1" Margin="2" VerticalAlignment="Center" />
<StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<Button Width="65" Margin="2">OK</Button>
<Button Width="65" Margin="2">Cancel</Button>
</StackPanel>
</Grid> </Grid>
</GroupBox> </extToolkit:ChildWindow>
</Grid>
<Grid Grid.Row="2" Margin="10"> </Grid>
<extToolkit:ChildWindow Width="350"
Caption="{Binding Text, ElementName=_txtCaption}"
IsModal="{Binding IsChecked, ElementName=_chkIsModal}"
Left="{Binding Value, ElementName=_txtLeft, Mode=TwoWay}"
Top="{Binding Value, ElementName=_txtTop, Mode=TwoWay}"
WindowStartupLocation="{Binding SelectedItem, ElementName=_cboWindowStartupLocations}"
WindowState="{Binding SelectedItem, ElementName=_cboWindowState}">
<Grid Margin="10" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="First Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="0" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter First Name" />
<TextBlock Grid.Row="1" Text="Last Name:" Margin="2" VerticalAlignment="Center" />
<extToolkit:WatermarkTextBox Grid.Row="1" Grid.Column="1" Margin="2" VerticalAlignment="Center" Watermark="Enter Last Name" />
<TextBlock Grid.Row="2" Text="Date of Birth:" Margin="2" VerticalAlignment="Center" />
<extToolkit:DateTimeUpDown Grid.Row="2" Grid.Column="1" Format="ShortDate" Margin="2" VerticalAlignment="Center" Watermark="Enter Date of Birth" />
<TextBlock Grid.Row="3" Text="Salary:" Margin="2" VerticalAlignment="Center" />
<extToolkit:IntegerUpDown Grid.Row="3" Grid.Column="1" FormatString="C2" Margin="2" VerticalAlignment="Center" Watermark="Enter Salary" />
<TextBlock Grid.Row="4" Text="Favorite Color:" Margin="2" VerticalAlignment="Center" />
<extToolkit:ColorPicker Grid.Row="4" Grid.Column="1" Margin="2" VerticalAlignment="Center" />
<StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
<Button Width="65" Margin="2">OK</Button>
<Button Width="65" Margin="2">Cancel</Button>
</StackPanel>
</Grid>
</extToolkit:ChildWindow>
</Grid>
</Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/HomeView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.ChildWindow.Views namespace Samples.Modules.ChildWindow.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

26
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/NavigationView.xaml

@ -1,11 +1,29 @@
<TreeViewItem x:Class="Samples.Modules.ChildWindow.Views.NavigationView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.ChildWindow.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.ChildWindow.Views" xmlns:views="clr-namespace:Samples.Modules.ChildWindow.Views"
Header="ChildWindow" Tag="{x:Type views:HomeView}"> Header="ChildWindow" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.ChildWindow/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.ChildWindow.Views namespace Samples.Modules.ChildWindow.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

49
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/ColorModule.cs

@ -1,6 +1,23 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.Color.Views; using Samples.Modules.Color.Views;
@ -8,19 +25,21 @@ using Samples.Modules.Color.Views;
namespace Samples.Modules.Color namespace Samples.Modules.Color
{ {
public class ColorModule: ModuleBase public class ColorModule : ModuleBase
{
public ColorModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public ColorModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Color")] [assembly: AssemblyTitle( "Samples.Modules.Color" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.Color")] [assembly: AssemblyProduct( "Samples.Modules.Color" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

75
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/HomeView.xaml

@ -1,12 +1,30 @@
<infControls:DemoView x:Class="Samples.Modules.Color.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Color.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:System="clr-namespace:System;assembly=mscorlib"
Title="Color Controls"> Title="Color Controls">
<Grid Margin="25"> <Grid Margin="25">
<!--<DataGrid x:Name="_dataGrid" <!--<DataGrid x:Name="_dataGrid"
AutoGenerateColumns="False" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserAddRows="False"
CanUserDeleteRows="False" CanUserDeleteRows="False"
@ -23,37 +41,40 @@
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid>--> </DataGrid>-->
<StackPanel> <StackPanel>
<extToolkit:CheckComboBox x:Name="_combo" HorizontalAlignment="Center" VerticalAlignment="Center" <extToolkit:CheckComboBox x:Name="_combo"
DisplayMemberPath="Color" HorizontalAlignment="Center"
ValueMemberPath="Level" VerticalAlignment="Center"
SelectedValue="{Binding SelectedValue}" DisplayMemberPath="Color"
SelectedItems="{Binding SelectedItems}"/> ValueMemberPath="Level"
SelectedValue="{Binding SelectedValue}"
SelectedItems="{Binding SelectedItems}" />
<!--<extToolkit:CheckComboBox x:Name="_combo" HorizontalAlignment="Center" VerticalAlignment="Center" <!--<extToolkit:CheckComboBox x:Name="_combo" HorizontalAlignment="Center" VerticalAlignment="Center"
SelectedValue="{Binding SelectedValues}" />--> SelectedValue="{Binding SelectedValues}" />-->
<!--<ComboBox x:Name="_combo2" HorizontalAlignment="Center" VerticalAlignment="Center" <!--<ComboBox x:Name="_combo2" HorizontalAlignment="Center" VerticalAlignment="Center"
IsEditable="True" IsEditable="True"
DisplayMemberPath="Color" DisplayMemberPath="Color"
/>--> />-->
<extToolkit:CheckListBox x:Name="_listBox" Height="250" <extToolkit:CheckListBox x:Name="_listBox"
DisplayMemberPath="Color" Height="250"
ValueMemberPath="Level" DisplayMemberPath="Color"
SelectedMemberPath="IsSelected" ValueMemberPath="Level"
SelectedValue="{Binding SelectedValue}" SelectedMemberPath="IsSelected"
SelectedItems="{Binding SelectedItems}"/> SelectedValue="{Binding SelectedValue}"
SelectedItems="{Binding SelectedItems}" />
<!--<extToolkit:CheckListBox x:Name="_listBox" Height="250" <!--<extToolkit:CheckListBox x:Name="_listBox" Height="250"
SelectedValue="{Binding SelectedValues}" SelectedValue="{Binding SelectedValues}"
/>--> />-->
<TextBlock Text="{Binding SelectedValue}" /> <TextBlock Text="{Binding SelectedValue}" />
<ListBox ItemsSource="{Binding SelectedItems}" Height="50" /> <ListBox ItemsSource="{Binding SelectedItems}" Height="50" />
<Button Click="Button_Click">Set</Button> <Button Click="Button_Click">Set</Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

328
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/HomeView.xaml.cs

@ -1,160 +1,198 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
using Microsoft.Practices.Prism.Regions; Extended WPF Toolkit
using System.ComponentModel;
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Color.Views namespace Samples.Modules.Color.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{
InitializeComponent();
DataContext = new Data();
//List<string> colors = new List<string>();
//colors.Add("1");
//colors.Add("2");
//colors.Add("3");
//colors.Add("4");
//colors.Add("5");
//colors.Add("6");
//colors.Add("7");
//colors.Add("8");
//colors.Add("9");
//colors.Add("10");
List<Person> colors = new List<Person>();
colors.Add( new Person( System.Windows.Media.Colors.Red, 0 ) );
colors.Add( new Person( System.Windows.Media.Colors.Purple, 1 )
{
IsSelected = true
} );
colors.Add( new Person( System.Windows.Media.Colors.Coral, 2 ) );
colors.Add( new Person( System.Windows.Media.Colors.MidnightBlue, 3 )
{
IsSelected = true
} );
colors.Add( new Person( System.Windows.Media.Colors.Green, 4 ) );
colors.Add( new Person( System.Windows.Media.Colors.Red, 5 ) );
colors.Add( new Person( System.Windows.Media.Colors.Purple, 6 ) );
colors.Add( new Person( System.Windows.Media.Colors.SaddleBrown, 7 ) );
colors.Add( new Person( System.Windows.Media.Colors.MidnightBlue, 8 ) );
colors.Add( new Person( System.Windows.Media.Colors.Green, 9 ) );
colors.Add( new Person( System.Windows.Media.Colors.Red, 10 ) );
colors.Add( new Person( System.Windows.Media.Colors.Purple, 11 ) );
colors.Add( new Person( System.Windows.Media.Colors.SaddleBrown, 12 ) );
colors.Add( new Person( System.Windows.Media.Colors.MidnightBlue, 13 ) );
colors.Add( new Person( System.Windows.Media.Colors.Green, 14 ) );
colors.Add( new Person( System.Windows.Media.Colors.Red, 15 ) );
colors.Add( new Person( System.Windows.Media.Colors.Purple, 16 ) );
colors.Add( new Person( System.Windows.Media.Colors.SaddleBrown, 17 ) );
colors.Add( new Person( System.Windows.Media.Colors.MidnightBlue, 18 ) );
colors.Add( new Person( System.Windows.Media.Colors.Green, 19 ) );
//_dataGrid.ItemsSource = colors;
//_chk.ItemsSource = colors;
_combo.ItemsSource = colors;
//_combo.SelectedValue = "1,3,5,7,9,";
_listBox.ItemsSource = colors;
//_listBox.SelectedValue = "1,3,5,7,9,";
}
private void Button_Click( object sender, System.Windows.RoutedEventArgs e )
{
( DataContext as Data ).SelectedValue = "1,3,5,7,9,";
}
}
public class Data : INotifyPropertyChanged
{
private string _selectedValues;// = "1,3,5,7,9,";
public string SelectedValue
{
get
{
return _selectedValues;
}
set
{
_selectedValues = value;
OnPropertyChanged( "SelectedValue" );
}
}
private ObservableCollection<Person> _selectedItems = new ObservableCollection<Person>();
public ObservableCollection<Person> SelectedItems
{
get
{
return _selectedItems;
}
set
{
_selectedItems = value;
OnPropertyChanged( "SelectedItems" );
}
}
public Data()
{ {
public HomeView()
{
InitializeComponent();
DataContext = new Data();
//List<string> colors = new List<string>();
//colors.Add("1");
//colors.Add("2");
//colors.Add("3");
//colors.Add("4");
//colors.Add("5");
//colors.Add("6");
//colors.Add("7");
//colors.Add("8");
//colors.Add("9");
//colors.Add("10");
List<Person> colors = new List<Person>();
colors.Add(new Person(System.Windows.Media.Colors.Red, 0));
colors.Add(new Person(System.Windows.Media.Colors.Purple, 1) { IsSelected = true });
colors.Add(new Person(System.Windows.Media.Colors.Coral, 2));
colors.Add(new Person(System.Windows.Media.Colors.MidnightBlue, 3) { IsSelected = true });
colors.Add(new Person(System.Windows.Media.Colors.Green, 4));
colors.Add(new Person(System.Windows.Media.Colors.Red, 5));
colors.Add(new Person(System.Windows.Media.Colors.Purple, 6));
colors.Add(new Person(System.Windows.Media.Colors.SaddleBrown, 7));
colors.Add(new Person(System.Windows.Media.Colors.MidnightBlue, 8));
colors.Add(new Person(System.Windows.Media.Colors.Green, 9));
colors.Add(new Person(System.Windows.Media.Colors.Red, 10));
colors.Add(new Person(System.Windows.Media.Colors.Purple, 11));
colors.Add(new Person(System.Windows.Media.Colors.SaddleBrown, 12));
colors.Add(new Person(System.Windows.Media.Colors.MidnightBlue, 13));
colors.Add(new Person(System.Windows.Media.Colors.Green, 14));
colors.Add(new Person(System.Windows.Media.Colors.Red, 15));
colors.Add(new Person(System.Windows.Media.Colors.Purple, 16));
colors.Add(new Person(System.Windows.Media.Colors.SaddleBrown, 17));
colors.Add(new Person(System.Windows.Media.Colors.MidnightBlue, 18));
colors.Add(new Person(System.Windows.Media.Colors.Green, 19));
//_dataGrid.ItemsSource = colors;
//_chk.ItemsSource = colors;
_combo.ItemsSource = colors;
//_combo.SelectedValue = "1,3,5,7,9,";
_listBox.ItemsSource = colors;
//_listBox.SelectedValue = "1,3,5,7,9,";
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
(DataContext as Data).SelectedValue = "1,3,5,7,9,";
}
} }
public class Data: INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged( string propertyName )
{ {
private string _selectedValues;// = "1,3,5,7,9,"; if( PropertyChanged != null )
public string SelectedValue PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
{
get
{
return _selectedValues;
}
set
{
_selectedValues = value;
OnPropertyChanged("SelectedValue");
}
}
private ObservableCollection<Person> _selectedItems = new ObservableCollection<Person>();
public ObservableCollection<Person> SelectedItems
{
get { return _selectedItems; }
set
{
_selectedItems = value;
OnPropertyChanged("SelectedItems");
}
}
public Data()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
} }
}
public class Person : INotifyPropertyChanged public class Person : INotifyPropertyChanged
{
private bool _isSelected;
public bool IsSelected
{ {
private bool _isSelected; get
public bool IsSelected {
{ return _isSelected;
get { return _isSelected; } }
set set
{ {
_isSelected = value; _isSelected = value;
OnPropertyChanged("IsSelected"); OnPropertyChanged( "IsSelected" );
} }
}
System.Windows.Media.Color _color;
public System.Windows.Media.Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged("Color");
}
}
int _level;
public int Level
{
get { return _level; }
set { _level = value; OnPropertyChanged("Level"); }
}
public Person()
{
}
public Person(System.Windows.Media.Color color, int level)
{
this._color = color;
this._level = level;
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
} }
System.Windows.Media.Color _color;
public System.Windows.Media.Color Color
{
get
{
return _color;
}
set
{
_color = value;
OnPropertyChanged( "Color" );
}
}
int _level;
public int Level
{
get
{
return _level;
}
set
{
_level = value;
OnPropertyChanged( "Level" );
}
}
public Person()
{
}
public Person( System.Windows.Media.Color color, int level )
{
this._color = color;
this._level = level;
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged( string propertyName )
{
if( PropertyChanged != null )
PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
}
}
} }

26
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/NavigationView.xaml

@ -1,11 +1,29 @@
<TreeViewItem x:Class="Samples.Modules.Color.Views.NavigationView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Color.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.Color.Views" xmlns:views="clr-namespace:Samples.Modules.Color.Views"
Header="Color" Tag="{x:Type views:HomeView}"> Header="Color" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Color/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.Color.Views namespace Samples.Modules.Color.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

49
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/DateTimeModule.cs

@ -1,25 +1,44 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.DateTime.Views; using Samples.Modules.DateTime.Views;
namespace Samples.Modules.DateTime namespace Samples.Modules.DateTime
{ {
public class DateTimeModule: ModuleBase public class DateTimeModule : ModuleBase
{
public DateTimeModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public DateTimeModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.DateTime")] [assembly: AssemblyTitle( "Samples.Modules.DateTime" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.DateTime")] [assembly: AssemblyProduct( "Samples.Modules.DateTime" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

26
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml

@ -1,10 +1,28 @@
<infControls:DemoView x:Class="Samples.Modules.DateTime.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.DateTime.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Title="DateTime Controls"> Title="DateTime Controls">
<Grid> <Grid>
<extToolkit:DateTimePicker IsReadOnly="False" /> <extToolkit:DateTimePicker IsReadOnly="False" />
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.DateTime.Views namespace Samples.Modules.DateTime.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/NavigationView.xaml

@ -1,11 +1,29 @@
<TreeViewItem x:Class="Samples.Modules.DateTime.Views.NavigationView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.DateTime.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.DateTime.Views" xmlns:views="clr-namespace:Samples.Modules.DateTime.Views"
Header="DateTime" Tag="{x:Type views:HomeView}"> Header="DateTime" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.DateTime.Views namespace Samples.Modules.DateTime.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

49
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/NumericModule.cs

@ -1,25 +1,44 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.Numeric.Views; using Samples.Modules.Numeric.Views;
namespace Samples.Modules.Numeric namespace Samples.Modules.Numeric
{ {
public class NumericModule: ModuleBase public class NumericModule : ModuleBase
{
public NumericModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public NumericModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Numeric")] [assembly: AssemblyTitle( "Samples.Modules.Numeric" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.Numeric")] [assembly: AssemblyProduct( "Samples.Modules.Numeric" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

26
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/HomeView.xaml

@ -1,9 +1,27 @@
<infControls:DemoView x:Class="Samples.Modules.Numeric.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Numeric.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Title="Numeric Controls"> Title="Numeric Controls">
<Grid> <Grid>
<TextBlock Text="Numeric View" /> <TextBlock Text="Numeric View" />
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/HomeView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Numeric.Views namespace Samples.Modules.Numeric.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/NavigationView.xaml

@ -1,11 +1,29 @@
<TreeViewItem x:Class="Samples.Modules.Numeric.Views.NavigationView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Numeric.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.Numeric.Views" xmlns:views="clr-namespace:Samples.Modules.Numeric.Views"
Header="Numeric" Tag="{x:Type views:HomeView}"> Header="Numeric" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Numeric/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.Numeric.Views namespace Samples.Modules.Numeric.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.PropertyGrid")] [assembly: AssemblyTitle( "Samples.Modules.PropertyGrid" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.PropertyGrid")] [assembly: AssemblyProduct( "Samples.Modules.PropertyGrid" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

61
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/PropertyGridModule.cs

@ -1,31 +1,50 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.PropertyGrid.Views; using Samples.Modules.PropertyGrid.Views;
namespace Samples.Modules.PropertyGrid namespace Samples.Modules.PropertyGrid
{ {
public class PropertyGridModule: ModuleBase public class PropertyGridModule : ModuleBase
{
public PropertyGridModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public PropertyGridModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { } Container.RegisterNavigationType( typeof( CustomEditors ) );
Container.RegisterNavigationType( typeof( CustomItemsSource ) );
protected override void InitializeModule() Container.RegisterNavigationType( typeof( DefaultEditors ) );
{ Container.RegisterNavigationType( typeof( ExpandableProperties ) );
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView)); Container.RegisterNavigationType( typeof( SpecifyingProperties ) );
} Container.RegisterNavigationType( typeof( BindingToStructs ) );
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
Container.RegisterNavigationType(typeof(CustomEditors));
Container.RegisterNavigationType(typeof(CustomItemsSource));
Container.RegisterNavigationType(typeof(DefaultEditors));
Container.RegisterNavigationType(typeof(ExpandableProperties));
Container.RegisterNavigationType(typeof(SpecifyingProperties));
Container.RegisterNavigationType(typeof(BindingToStructs));
}
} }
}
} }

28
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml

@ -1,9 +1,27 @@
<UserControl x:Class="Samples.Modules.PropertyGrid.LastNameUserControlEditor" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<UserControl x:Class="Samples.Modules.PropertyGrid.LastNameUserControlEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="_uc"> x:Name="_uc">
<StackPanel> <StackPanel>
<TextBox Text="{Binding Value, ElementName=_uc}" Background="YellowGreen" /> <TextBox Text="{Binding Value, ElementName=_uc}" Background="YellowGreen" />
<Button Click="Button_Click">Clear</Button> <Button Click="Button_Click">Clear</Button>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

86
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Resources/LastNameUserControlEditor.xaml.cs

@ -1,39 +1,63 @@
using System.Windows; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Microsoft.Windows.Controls.PropertyGrid.Editors;
using System.Windows.Data; using System.Windows.Data;
using Microsoft.Windows.Controls.PropertyGrid.Editors;
namespace Samples.Modules.PropertyGrid namespace Samples.Modules.PropertyGrid
{ {
/// <summary> /// <summary>
/// Interaction logic for LastNameUserControlEditor.xaml /// Interaction logic for LastNameUserControlEditor.xaml
/// </summary> /// </summary>
public partial class LastNameUserControlEditor : UserControl, ITypeEditor public partial class LastNameUserControlEditor : UserControl, ITypeEditor
{
public LastNameUserControlEditor()
{
InitializeComponent();
}
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( "Value", typeof( string ), typeof( LastNameUserControlEditor ), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault ) );
public string Value
{
get
{
return ( string )GetValue( ValueProperty );
}
set
{
SetValue( ValueProperty, value );
}
}
private void Button_Click( object sender, RoutedEventArgs e )
{
Value = string.Empty;
}
public FrameworkElement ResolveEditor( Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem )
{ {
public LastNameUserControlEditor() Binding binding = new Binding( "Value" );
{ binding.Source = propertyItem;
InitializeComponent(); binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
} BindingOperations.SetBinding( this, LastNameUserControlEditor.ValueProperty, binding );
return this;
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(LastNameUserControlEditor), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Value = string.Empty;
}
public FrameworkElement ResolveEditor(Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem)
{
Binding binding = new Binding("Value");
binding.Source = propertyItem;
binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(this, LastNameUserControlEditor.ValueProperty, binding);
return this;
}
} }
}
} }

104
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/BindingToStructs.xaml

@ -1,4 +1,22 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.BindingToStructs" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.BindingToStructs"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
@ -6,46 +24,46 @@
xmlns:local="clr-namespace:Samples.Modules.PropertyGrid.Views" xmlns:local="clr-namespace:Samples.Modules.PropertyGrid.Views"
Title="Binding to Structs"> Title="Binding to Structs">
<infControls:DemoView.Resources> <infControls:DemoView.Resources>
<local:DimensionsConverter x:Key="DimensionsConverter" /> <local:DimensionsConverter x:Key="DimensionsConverter" />
</infControls:DemoView.Resources> </infControls:DemoView.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="When the SelectedObject contains properties of type Struct youmay find that edits performed in the PropertyGrid do not function properly. This is because Structs are passed by value. Meaning that the PropertyGrid receives a copy of the Struct and not a reference. When this happens, the data binding expressions end up binding to and modifying that copy rather than the original values." <TextBlock Text="When the SelectedObject contains properties of type Struct youmay find that edits performed in the PropertyGrid do not function properly. This is because Structs are passed by value. Meaning that the PropertyGrid receives a copy of the Struct and not a reference. When this happens, the data binding expressions end up binding to and modifying that copy rather than the original values."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Binding to Structs:" Style="{StaticResource Header}" /> <TextBlock Text="Binding to Structs:" Style="{StaticResource Header}" />
<TextBlock Text="The solution to this problem is to create a custom editor and provide an IValueConverter to handle the proper conversion of the Struct values." TextWrapping="Wrap" /> <TextBlock Text="The solution to this problem is to create a custom editor and provide an IValueConverter to handle the proper conversion of the Struct values." TextWrapping="Wrap" />
<extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" > <extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10">
<extToolkit:PropertyGrid.EditorDefinitions> <extToolkit:PropertyGrid.EditorDefinitions>
<extToolkit:EditorDefinition TargetType="{x:Type local:Dimension}"> <extToolkit:EditorDefinition TargetType="{x:Type local:Dimension}">
<extToolkit:EditorDefinition.EditorTemplate> <extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate> <DataTemplate>
<Grid Margin="5" > <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Text="Height: " /> <TextBlock Text="Height: " />
<TextBox Grid.Column="1" Text="{Binding Path=Value, Converter={StaticResource DimensionsConverter},ConverterParameter=Height}" /> <TextBox Grid.Column="1" Text="{Binding Path=Value, Converter={StaticResource DimensionsConverter},ConverterParameter=Height}" />
<TextBlock Grid.Row="1" Text="Weight: " /> <TextBlock Grid.Row="1" Text="Weight: " />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Value, Converter={StaticResource DimensionsConverter},ConverterParameter=Weight}" /> <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Value, Converter={StaticResource DimensionsConverter},ConverterParameter=Weight}" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate> </extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition> </extToolkit:EditorDefinition>
</extToolkit:PropertyGrid.EditorDefinitions> </extToolkit:PropertyGrid.EditorDefinitions>
</extToolkit:PropertyGrid> </extToolkit:PropertyGrid>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

170
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/BindingToStructs.xaml.cs

@ -1,96 +1,118 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
using System.Windows.Controls;
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.ComponentModel;
using System.Windows.Data; 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;
using Samples.Infrastructure.Controls;
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using System.ComponentModel; using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for BindingToStructs.xaml /// Interaction logic for BindingToStructs.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class BindingToStructs : DemoView public partial class BindingToStructs : DemoView
{
public BindingToStructs()
{ {
public BindingToStructs() InitializeComponent();
{ _propertyGrid.SelectedObject = Person.CreatePerson();
InitializeComponent();
_propertyGrid.SelectedObject = Person.CreatePerson();
}
public class Person
{
[Category("Information")]
[DisplayName("First Name")]
[Description("This property uses a TextBox as the default editor.")]
public string FirstName { get; set; }
[Category("Information")]
[DisplayName("Last Name")]
[Description("This property uses a TextBox as the default editor.")]
public string LastName { get; set; }
public Dimension Dimensions { get; set; }
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.Dimensions = new Dimension() { Height = 75.0, Weight = 185.76 };
return person;
}
}
} }
public struct Dimension public class Person
{ {
public double Height; [Category( "Information" )]
public double Weight; [DisplayName( "First Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string FirstName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Last Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string LastName
{
get;
set;
}
public Dimension(double height, double weight) public Dimension Dimensions
{
get;
set;
}
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.Dimensions = new Dimension()
{ {
this.Height = height; Height = 75.0,
this.Weight = weight; Weight = 185.76
} };
return person;
}
} }
}
public struct Dimension
{
public double Height;
public double Weight;
public class DimensionsConverter : IValueConverter public Dimension( double height, double weight )
{ {
static Dimension _originalValue; // the static struct that stores original value at the start of editing this.Height = height;
this.Weight = weight;
}
}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) public class DimensionsConverter : IValueConverter
{ {
_originalValue = ((Dimension)value); static Dimension _originalValue; // the static struct that stores original value at the start of editing
if (parameter.ToString() == "Height") public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
return ((Dimension)value).Height; {
if (parameter.ToString() == "Weight") _originalValue = ( ( Dimension )value );
return ((Dimension)value).Weight;
return _originalValue; if( parameter.ToString() == "Height" )
} return ( ( Dimension )value ).Height;
if( parameter.ToString() == "Weight" )
return ( ( Dimension )value ).Weight;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) return _originalValue;
{ }
if (parameter.ToString() == "Height")
_originalValue = new Dimension(double.Parse(value.ToString()), _originalValue.Weight);
if (parameter.ToString() == "Weight")
_originalValue = new Dimension(_originalValue.Height, double.Parse(value.ToString()));
return _originalValue; public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( parameter.ToString() == "Height" )
_originalValue = new Dimension( double.Parse( value.ToString() ), _originalValue.Weight );
if( parameter.ToString() == "Weight" )
_originalValue = new Dimension( _originalValue.Height, double.Parse( value.ToString() ) );
} return _originalValue;
} }
}
} }

145
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml

@ -1,70 +1,89 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.CustomEditors" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.CustomEditors"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Custom Editors"> Title="Custom Editors">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="This example demonstrates the various methods of creating and using custom editors. You can supply your own editor based on a Type, a property name, or both. To supply your own editor for a property you have to create an EditorDefinition for the PropertyGrid."
TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Custom Editors with a DataTemplate:" Style="{StaticResource Header}" />
<TextBlock Text="You can override the default editors with your own custom editors with a DataTemplate. Simply define an EditorDefinition that either targets a Type, property name, or both and set the EditorDefinition.EditorTemplate to an instance of a DataTemplate. Be sure to bind your custom editor to the bound property item's Value property." TextWrapping="Wrap" />
<extToolkit:PropertyGrid x:Name="_propertyGrid1" Width="450" Margin="10">
<extToolkit:PropertyGrid.EditorDefinitions>
<!-- This EditorDefinition will provide a TextBox to any property that is of type HorizontalAlignment, replacing the default ComboBox editor. -->
<extToolkit:EditorDefinition TargetType="{x:Type HorizontalAlignment}">
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Green" Text="{Binding Value}" />
<!-- Always bind your editor's value to the bound property's Value -->
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
<!-- This EditorDefinition will provide a TextBlock to any property that has any of the defined property names, replacing the default editor. -->
<extToolkit:EditorDefinition>
<extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:PropertyDefinition Name="Age" />
<extToolkit:PropertyDefinition Name="WritingFont" />
<extToolkit:PropertyDefinition Name="Spouse" />
</extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBlock Background="Yellow" Text="{Binding Value}" />
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
<TextBlock Text="This example demonstrates the various methods of creating and using custom editors. You can supply your own editor based on a Type, a property name, or both. To supply your own editor for a property you have to create an EditorDefinition for the PropertyGrid." <!-- This EditorDefinition will provide a TextBox to any property that is of type Boolean and that has any of the defined property names, replacing the default editor. -->
TextWrapping="Wrap" /> <extToolkit:EditorDefinition TargetType="{x:Type sys:Boolean}">
<extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:PropertyDefinition Name="DateOfBirth" />
<extToolkit:PropertyDefinition Name="LastName" />
</extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Red" Text="{Binding Value}" />
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
<StackPanel Grid.Row="1" Margin="10"> </extToolkit:PropertyGrid.EditorDefinitions>
<TextBlock Text="Custom Editors with a DataTemplate:" Style="{StaticResource Header}" /> </extToolkit:PropertyGrid>
<TextBlock Text="You can override the default editors with your own custom editors with a DataTemplate. Simply define an EditorDefinition that either targets a Type, property name, or both and set the EditorDefinition.EditorTemplate to an instance of a DataTemplate. Be sure to bind your custom editor to the bound property item's Value property." TextWrapping="Wrap"/> </StackPanel>
<extToolkit:PropertyGrid x:Name="_propertyGrid1" Width="450" Margin="10">
<extToolkit:PropertyGrid.EditorDefinitions>
<!-- This EditorDefinition will provide a TextBox to any property that is of type HorizontalAlignment, replacing the default ComboBox editor. -->
<extToolkit:EditorDefinition TargetType="{x:Type HorizontalAlignment}">
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Green" Text="{Binding Value}" /> <!-- Always bind your editor's value to the bound property's Value -->
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
<!-- This EditorDefinition will provide a TextBlock to any property that has any of the defined property names, replacing the default editor. -->
<extToolkit:EditorDefinition>
<extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:PropertyDefinition Name="Age" />
<extToolkit:PropertyDefinition Name="WritingFont" />
<extToolkit:PropertyDefinition Name="Spouse" />
</extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBlock Background="Yellow" Text="{Binding Value}" />
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
<!-- This EditorDefinition will provide a TextBox to any property that is of type Boolean and that has any of the defined property names, replacing the default editor. -->
<extToolkit:EditorDefinition TargetType="{x:Type sys:Boolean}">
<extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:PropertyDefinition Name="DateOfBirth" />
<extToolkit:PropertyDefinition Name="LastName" />
</extToolkit:EditorDefinition.PropertiesDefinitions>
<extToolkit:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBox Background="Red" Text="{Binding Value}" />
</DataTemplate>
</extToolkit:EditorDefinition.EditorTemplate>
</extToolkit:EditorDefinition>
</extToolkit:PropertyGrid.EditorDefinitions>
</extToolkit:PropertyGrid>
</StackPanel>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Custom Editors with an Attribute:" Style="{StaticResource Header}" /> <TextBlock Text="Custom Editors with an Attribute:" Style="{StaticResource Header}" />
<TextBlock Text="You can supply editors for a property by using the System.ComponentModel.EditorAttribute. In order to provide an editor with an attribute, the editor MUST implement the ITypeEditor interface. Your editor can be a simple class or a complex UserControl." TextWrapping="Wrap" /> <TextBlock Text="You can supply editors for a property by using the System.ComponentModel.EditorAttribute. In order to provide an editor with an attribute, the editor MUST implement the ITypeEditor interface. Your editor can be a simple class or a complex UserControl." TextWrapping="Wrap" />
<extToolkit:PropertyGrid x:Name="_propertyGrid2" Width="450" Margin="10"/> <extToolkit:PropertyGrid x:Name="_propertyGrid2" Width="450" Margin="10" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

372
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomEditors.xaml.cs

@ -1,159 +1,245 @@
using Samples.Infrastructure.Controls; /************************************************************************
using System.ComponentModel;
using System.Collections.Generic; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media;
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for CustomEditors.xaml /// Interaction logic for CustomEditors.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class CustomEditors : DemoView public partial class CustomEditors : DemoView
{
public CustomEditors()
{ {
public CustomEditors() InitializeComponent();
{ _propertyGrid1.SelectedObject = Person.CreatePerson();
InitializeComponent(); _propertyGrid2.SelectedObject = CustomAttributEditorPerson.CreateCustomAttributEditorPerson();
_propertyGrid1.SelectedObject = Person.CreatePerson(); }
_propertyGrid2.SelectedObject = CustomAttributEditorPerson.CreateCustomAttributEditorPerson();
}
public class Person public class Person
{ {
[Category("Information")] [Category( "Information" )]
[DisplayName("First Name")] [DisplayName( "First Name" )]
[Description("This property uses a TextBox as the default editor.")] [Description( "This property uses a TextBox as the default editor." )]
public string FirstName { get; set; } public string FirstName
{
[Category("Information")] get;
[DisplayName("Last Name")] set;
[Description("This property uses a TextBox as the default editor.")] }
public string LastName { get; set; }
[Category( "Information" )]
[Category("Information")] [DisplayName( "Last Name" )]
[DisplayName("Date of Birth")] [Description( "This property uses a TextBox as the default editor." )]
[Description("This property uses the DateTimeUpDown as the default editor.")] public string LastName
public DateTime DateOfBirth { get; set; } {
get;
[DisplayName("Grade Point Average")] set;
[Description("This property uses the DoubleUpDown as the default editor.")] }
public double GradePointAvg { get; set; }
[Category( "Information" )]
[Category("Information")] [DisplayName( "Date of Birth" )]
[Description("This property uses the IntegerUpDown as the default editor.")] [Description( "This property uses the DateTimeUpDown as the default editor." )]
public int Age { get; set; } public DateTime DateOfBirth
{
[Category("Information")] get;
[DisplayName("Is Male")] set;
[Description("This property uses a CheckBox as the default editor.")] }
public bool IsMale { get; set; }
[DisplayName( "Grade Point Average" )]
[Category("Information")] [Description( "This property uses the DoubleUpDown as the default editor." )]
[DisplayName("Favorite Color")] public double GradePointAvg
[Description("This property uses the ColorPicker as the default editor.")] {
public Color FavoriteColor { get; set; } get;
set;
[Category("Writing")] }
[DisplayName("Writing Hand")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] [Category( "Information" )]
public HorizontalAlignment WritingHand { get; set; } [Description( "This property uses the IntegerUpDown as the default editor." )]
public int Age
[Category("Writing")] {
[DisplayName("Writing Font")] get;
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] set;
public FontFamily WritingFont { get; set; } }
[Category("Writing")] [Category( "Information" )]
[DisplayName("Writing Font Size")] [DisplayName( "Is Male" )]
[Description("This property uses the DoubleUpDown as the default editor.")] [Description( "This property uses a CheckBox as the default editor." )]
public double WritingFontSize { get; set; } public bool IsMale
{
[Category("Conections")] get;
[DisplayName("Pet Names")] set;
[Description("This property uses the PrimitiveTypeCollectionEditor as the default editor.")] }
public List<String> PetNames { get; set; }
[Category( "Information" )]
[Category("Conections")] [DisplayName( "Favorite Color" )]
[Description("This property uses the CollectionEditor as the default editor.")] [Description( "This property uses the ColorPicker as the default editor." )]
public List<Person> Friends { get; set; } public Color FavoriteColor
{
[Category("Conections")] get;
[Description("This property is a complex property and has no default editor.")] set;
public Person Spouse { get; set; } }
public static Person CreatePerson() [Category( "Writing" )]
{ [DisplayName( "Writing Hand" )]
var person = new Person(); [Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
person.FirstName = "John"; public HorizontalAlignment WritingHand
person.LastName = "Doe"; {
person.DateOfBirth = new DateTime(1975, 1, 23); get;
person.Age = DateTime.Today.Year - person.DateOfBirth.Year; set;
person.GradePointAvg = 3.98; }
person.IsMale = true;
person.FavoriteColor = Colors.Blue; [Category( "Writing" )]
person.WritingHand = System.Windows.HorizontalAlignment.Right; [DisplayName( "Writing Font" )]
person.WritingFont = new FontFamily("Arial"); [Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
person.WritingFontSize = 12.5; public FontFamily WritingFont
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" }; {
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } }; get;
person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" }; set;
return person; }
}
} [Category( "Writing" )]
[DisplayName( "Writing Font Size" )]
public class CustomAttributEditorPerson [Description( "This property uses the DoubleUpDown as the default editor." )]
public double WritingFontSize
{
get;
set;
}
[Category( "Conections" )]
[DisplayName( "Pet Names" )]
[Description( "This property uses the PrimitiveTypeCollectionEditor as the default editor." )]
public List<String> PetNames
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property uses the CollectionEditor as the default editor." )]
public List<Person> Friends
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property is a complex property and has no default editor." )]
public Person Spouse
{
get;
set;
}
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime( 1975, 1, 23 );
person.Age = DateTime.Today.Year - person.DateOfBirth.Year;
person.GradePointAvg = 3.98;
person.IsMale = true;
person.FavoriteColor = Colors.Blue;
person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily( "Arial" );
person.WritingFontSize = 12.5;
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" };
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } };
person.Spouse = new Person()
{ {
[Category("Information")] FirstName = "Jane",
[DisplayName("First Name")] LastName = "Doe"
[Description("This property uses a TextBox as the default editor.")] };
//This custom editor is a Class that implements the ITypeEditor interface return person;
[Editor(typeof(FirstNameEditor), typeof(FirstNameEditor))] }
public string FirstName { get; set; }
[Category("Information")]
[DisplayName("Last Name")]
[Description("This property uses a TextBox as the default editor.")]
//This custom editor is a UserControl that implements the ITypeEditor interface
[Editor(typeof(LastNameUserControlEditor), typeof(LastNameUserControlEditor))]
public string LastName { get; set; }
[Category("Information")]
[DisplayName("Date of Birth")]
[Description("This property uses the DateTimeUpDown as the default editor.")]
public DateTime DateOfBirth { get; set; }
public static CustomAttributEditorPerson CreateCustomAttributEditorPerson()
{
var person = new CustomAttributEditorPerson();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime(1975, 1, 23);
return person;
}
}
} }
//Custom editors that are used as attributes MUST implement the ITypeEditor interface. public class CustomAttributEditorPerson
public class FirstNameEditor : Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor
{ {
public FrameworkElement ResolveEditor(Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem) [Category( "Information" )]
{ [DisplayName( "First Name" )]
TextBox textBox = new TextBox(); [Description( "This property uses a TextBox as the default editor." )]
textBox.Background = new SolidColorBrush(Colors.Red); //This custom editor is a Class that implements the ITypeEditor interface
[Editor( typeof( FirstNameEditor ), typeof( FirstNameEditor ) )]
//create the binding from the bound property item to the editor public string FirstName
var _binding = new Binding("Value"); //bind to the Value property of the PropertyItem {
_binding.Source = propertyItem; get;
_binding.ValidatesOnExceptions = true; set;
_binding.ValidatesOnDataErrors = true; }
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(textBox, TextBox.TextProperty, _binding); [Category( "Information" )]
return textBox; [DisplayName( "Last Name" )]
} [Description( "This property uses a TextBox as the default editor." )]
//This custom editor is a UserControl that implements the ITypeEditor interface
[Editor( typeof( LastNameUserControlEditor ), typeof( LastNameUserControlEditor ) )]
public string LastName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Date of Birth" )]
[Description( "This property uses the DateTimeUpDown as the default editor." )]
public DateTime DateOfBirth
{
get;
set;
}
public static CustomAttributEditorPerson CreateCustomAttributEditorPerson()
{
var person = new CustomAttributEditorPerson();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime( 1975, 1, 23 );
return person;
}
}
}
//Custom editors that are used as attributes MUST implement the ITypeEditor interface.
public class FirstNameEditor : Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor
{
public FrameworkElement ResolveEditor( Microsoft.Windows.Controls.PropertyGrid.PropertyItem propertyItem )
{
TextBox textBox = new TextBox();
textBox.Background = new SolidColorBrush( Colors.Red );
//create the binding from the bound property item to the editor
var _binding = new Binding( "Value" ); //bind to the Value property of the PropertyItem
_binding.Source = propertyItem;
_binding.ValidatesOnExceptions = true;
_binding.ValidatesOnDataErrors = true;
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding( textBox, TextBox.TextProperty, _binding );
return textBox;
} }
}
} }

60
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml

@ -1,23 +1,41 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.CustomItemsSource" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.CustomItemsSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Custom ItemsSource"> Title="Custom ItemsSource">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="Sometimes it is desirable to want to provide a collection of values represented by a ComboBox for a given property. The PropertyGrid supports this scenario by create a class that implements IItemsSource and decorating your property with the ItemsSourceAttribute." <TextBlock Text="Sometimes it is desirable to want to provide a collection of values represented by a ComboBox for a given property. The PropertyGrid supports this scenario by create a class that implements IItemsSource and decorating your property with the ItemsSourceAttribute."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Providing a Custom ItemsSource:" Style="{StaticResource Header}" /> <TextBlock Text="Providing a Custom ItemsSource:" Style="{StaticResource Header}" />
<TextBlock Text="This example uses a collection of Doubles to represent the available options for the WritingFontSize property." TextWrapping="Wrap"/> <TextBlock Text="This example uses a collection of Doubles to represent the available options for the WritingFontSize property." TextWrapping="Wrap" />
<extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10"/> <extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

186
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/CustomItemsSource.xaml.cs

@ -1,4 +1,22 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -8,87 +26,111 @@ using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for CustomItemsSource.xaml /// Interaction logic for CustomItemsSource.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class CustomItemsSource : DemoView public partial class CustomItemsSource : DemoView
{
public CustomItemsSource()
{ {
public CustomItemsSource() InitializeComponent();
{ _propertyGrid.SelectedObject = Person.CreatePerson();
InitializeComponent(); }
_propertyGrid.SelectedObject = Person.CreatePerson();
}
public class Person public class Person
{ {
[Category("Information")] [Category( "Information" )]
[DisplayName("First Name")] [DisplayName( "First Name" )]
[Description("This property uses a TextBox as the default editor.")] [Description( "This property uses a TextBox as the default editor." )]
public string FirstName { get; set; } public string FirstName
{
get;
set;
}
[Category("Information")] [Category( "Information" )]
[DisplayName("Last Name")] [DisplayName( "Last Name" )]
[Description("This property uses a TextBox as the default editor.")] [Description( "This property uses a TextBox as the default editor." )]
public string LastName { get; set; } public string LastName
{
get;
set;
}
[Category("Information")] [Category( "Information" )]
[DisplayName("Date of Birth")] [DisplayName( "Date of Birth" )]
[Description("This property uses the DateTimeUpDown as the default editor.")] [Description( "This property uses the DateTimeUpDown as the default editor." )]
public DateTime DateOfBirth { get; set; } public DateTime DateOfBirth
{
get;
set;
}
[Category("Writing")] [Category( "Writing" )]
[DisplayName("Writing Hand")] [DisplayName( "Writing Hand" )]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] [Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public HorizontalAlignment WritingHand { get; set; } public HorizontalAlignment WritingHand
{
get;
set;
}
[Category("Writing")] [Category( "Writing" )]
[DisplayName("Writing Font")] [DisplayName( "Writing Font" )]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")] [Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public FontFamily WritingFont { get; set; } public FontFamily WritingFont
{
get;
set;
}
[Category("Writing")] [Category( "Writing" )]
[DisplayName("Writing Font Size")] [DisplayName( "Writing Font Size" )]
[Description("This property uses the DoubleUpDown as the default editor.")] [Description( "This property uses the DoubleUpDown as the default editor." )]
[ItemsSource(typeof(FontSizeItemsSource))] [ItemsSource( typeof( FontSizeItemsSource ) )]
public double WritingFontSize { get; set; } public double WritingFontSize
{
get;
set;
}
public static Person CreatePerson() public static Person CreatePerson()
{ {
var person = new Person(); var person = new Person();
person.FirstName = "John"; person.FirstName = "John";
person.LastName = "Doe"; person.LastName = "Doe";
person.DateOfBirth = new DateTime(1975, 1, 23); person.DateOfBirth = new DateTime( 1975, 1, 23 );
person.WritingHand = System.Windows.HorizontalAlignment.Right; person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily("Arial"); person.WritingFont = new FontFamily( "Arial" );
person.WritingFontSize = 12.0; person.WritingFontSize = 12.0;
return person; return person;
} }
}
} }
}
public class FontSizeItemsSource : IItemsSource public class FontSizeItemsSource : IItemsSource
{
public ItemCollection GetValues()
{ {
public ItemCollection GetValues() ItemCollection sizes = new ItemCollection();
{ sizes.Add( 5.0, "Five" );
ItemCollection sizes = new ItemCollection(); sizes.Add( 5.5 );
sizes.Add(5.0, "Five"); sizes.Add( 6.0, "Six" );
sizes.Add(5.5); sizes.Add( 6.5 );
sizes.Add(6.0, "Six"); sizes.Add( 7.0, "Seven" );
sizes.Add(6.5); sizes.Add( 7.5 );
sizes.Add(7.0, "Seven"); sizes.Add( 8.0, "Eight" );
sizes.Add(7.5); sizes.Add( 8.5 );
sizes.Add(8.0, "Eight"); sizes.Add( 9.0, "Nine" );
sizes.Add(8.5); sizes.Add( 9.5 );
sizes.Add(9.0, "Nine"); sizes.Add( 10.0 );
sizes.Add(9.5); sizes.Add( 12.0, "Twelve" );
sizes.Add(10.0); sizes.Add( 14.0 );
sizes.Add(12.0, "Twelve"); sizes.Add( 16.0 );
sizes.Add(14.0); sizes.Add( 18.0 );
sizes.Add(16.0); sizes.Add( 20.0 );
sizes.Add(18.0); return sizes;
sizes.Add(20.0);
return sizes;
}
} }
}
} }

54
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml

@ -1,21 +1,39 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.DefaultEditors" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.DefaultEditors"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Default Editors"> Title="Default Editors">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="This example demonstrates the default editors provided by the PropertyGrid." <TextBlock Text="This example demonstrates the default editors provided by the PropertyGrid."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Default Editors:" Style="{StaticResource Header}" /> <TextBlock Text="Default Editors:" Style="{StaticResource Header}" />
<extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10"/> <extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

260
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/DefaultEditors.xaml.cs

@ -1,106 +1,180 @@
using Samples.Infrastructure.Controls; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media;
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for DefaultEditors.xaml /// Interaction logic for DefaultEditors.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class DefaultEditors : DemoView public partial class DefaultEditors : DemoView
{
public DefaultEditors()
{ {
public DefaultEditors() InitializeComponent();
{ _propertyGrid.SelectedObject = Person.CreatePerson();
InitializeComponent(); }
_propertyGrid.SelectedObject = Person.CreatePerson();
} public class Person
{
[Category( "Information" )]
[DisplayName( "First Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string FirstName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Last Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string LastName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Date of Birth" )]
[Description( "This property uses the DateTimeUpDown as the default editor." )]
public DateTime DateOfBirth
{
get;
set;
}
[DisplayName( "Grade Point Average" )]
[Description( "This property uses the DoubleUpDown as the default editor." )]
public double GradePointAvg
{
get;
set;
}
[Category( "Information" )]
[Description( "This property uses the IntegerUpDown as the default editor." )]
public int Age
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Is Male" )]
[Description( "This property uses a CheckBox as the default editor." )]
public bool IsMale
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Favorite Color" )]
[Description( "This property uses the ColorPicker as the default editor." )]
public Color FavoriteColor
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Hand" )]
[Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public HorizontalAlignment WritingHand
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font" )]
[Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public FontFamily WritingFont
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font Size" )]
[Description( "This property uses the DoubleUpDown as the default editor." )]
public double WritingFontSize
{
get;
set;
}
[Category( "Conections" )]
[DisplayName( "Pet Names" )]
[Description( "This property uses the PrimitiveTypeCollectionEditor as the default editor." )]
public List<String> PetNames
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property uses the CollectionEditor as the default editor." )]
public List<Person> Friends
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property is a complex property and has no default editor." )]
public Person Spouse
{
get;
set;
}
public class Person public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime( 1975, 1, 23 );
person.Age = DateTime.Today.Year - person.DateOfBirth.Year;
person.GradePointAvg = 3.98;
person.IsMale = true;
person.FavoriteColor = Colors.Blue;
person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily( "Arial" );
person.WritingFontSize = 12.5;
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" };
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } };
person.Spouse = new Person()
{ {
[Category("Information")] FirstName = "Jane",
[DisplayName("First Name")] LastName = "Doe"
[Description("This property uses a TextBox as the default editor.")] };
public string FirstName { get; set; } return person;
}
[Category("Information")]
[DisplayName("Last Name")]
[Description("This property uses a TextBox as the default editor.")]
public string LastName { get; set; }
[Category("Information")]
[DisplayName("Date of Birth")]
[Description("This property uses the DateTimeUpDown as the default editor.")]
public DateTime DateOfBirth { get; set; }
[DisplayName("Grade Point Average")]
[Description("This property uses the DoubleUpDown as the default editor.")]
public double GradePointAvg { get; set; }
[Category("Information")]
[Description("This property uses the IntegerUpDown as the default editor.")]
public int Age { get; set; }
[Category("Information")]
[DisplayName("Is Male")]
[Description("This property uses a CheckBox as the default editor.")]
public bool IsMale { get; set; }
[Category("Information")]
[DisplayName("Favorite Color")]
[Description("This property uses the ColorPicker as the default editor.")]
public Color FavoriteColor { get; set; }
[Category("Writing")]
[DisplayName("Writing Hand")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")]
public HorizontalAlignment WritingHand { get; set; }
[Category("Writing")]
[DisplayName("Writing Font")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")]
public FontFamily WritingFont { get; set; }
[Category("Writing")]
[DisplayName("Writing Font Size")]
[Description("This property uses the DoubleUpDown as the default editor.")]
public double WritingFontSize { get; set; }
[Category("Conections")]
[DisplayName("Pet Names")]
[Description("This property uses the PrimitiveTypeCollectionEditor as the default editor.")]
public List<String> PetNames { get; set; }
[Category("Conections")]
[Description("This property uses the CollectionEditor as the default editor.")]
public List<Person> Friends { get; set; }
[Category("Conections")]
[Description("This property is a complex property and has no default editor.")]
public Person Spouse { get; set; }
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime(1975, 1, 23);
person.Age = DateTime.Today.Year - person.DateOfBirth.Year;
person.GradePointAvg = 3.98;
person.IsMale = true;
person.FavoriteColor = Colors.Blue;
person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily("Arial");
person.WritingFontSize = 12.5;
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" };
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } };
person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" };
return person;
}
}
} }
}
} }

60
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml

@ -1,23 +1,41 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.ExpandableProperties" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.ExpandableProperties"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Exandable Properties"> Title="Exandable Properties">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="Sometimes it is neccessary to show the properties of a complex object. The PropertyGrid supports this scenario and allows you to drill down into a property's heirarchy. To enable this behavior you must decorate your property with the ExpandableObject attribute." <TextBlock Text="Sometimes it is neccessary to show the properties of a complex object. The PropertyGrid supports this scenario and allows you to drill down into a property's heirarchy. To enable this behavior you must decorate your property with the ExpandableObject attribute."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Expandable Properties:" Style="{StaticResource Header}" /> <TextBlock Text="Expandable Properties:" Style="{StaticResource Header}" />
<TextBlock Text="In this example the Spouse property has been decorated with the ExpandableObject attribute. Notice how you can drill down into the Spouse properties." TextWrapping="Wrap" /> <TextBlock Text="In this example the Spouse property has been decorated with the ExpandableObject attribute. Notice how you can drill down into the Spouse properties." TextWrapping="Wrap" />
<extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" /> <extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

141
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/ExpandableProperties.xaml.cs

@ -1,62 +1,101 @@
using Samples.Infrastructure.Controls; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic;
using System;
using System.Windows.Media; using System.Windows.Media;
using System.Windows;
using Microsoft.Windows.Controls.PropertyGrid.Attributes; using Microsoft.Windows.Controls.PropertyGrid.Attributes;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for ExpandableProperties.xaml /// Interaction logic for ExpandableProperties.xaml
/// </summary> /// </summary>
public partial class ExpandableProperties : DemoView public partial class ExpandableProperties : DemoView
{
public ExpandableProperties()
{ {
public ExpandableProperties() InitializeComponent();
{ _propertyGrid.SelectedObject = Person.CreatePerson();
InitializeComponent(); }
_propertyGrid.SelectedObject = Person.CreatePerson();
} public class Person
{
[Category( "Information" )]
[DisplayName( "First Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string FirstName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Last Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string LastName
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font" )]
[Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public FontFamily WritingFont
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font Size" )]
[Description( "This property uses the DoubleUpDown as the default editor." )]
public double WritingFontSize
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property is a complex property and has no default editor." )]
[ExpandableObject]
public Person Spouse
{
get;
set;
}
public class Person public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.WritingFont = new FontFamily( "Arial" );
person.WritingFontSize = 12.5;
person.Spouse = new Person()
{ {
[Category("Information")] FirstName = "Jane",
[DisplayName("First Name")] LastName = "Doe"
[Description("This property uses a TextBox as the default editor.")] };
public string FirstName { get; set; } return person;
}
[Category("Information")]
[DisplayName("Last Name")]
[Description("This property uses a TextBox as the default editor.")]
public string LastName { get; set; }
[Category("Writing")]
[DisplayName("Writing Font")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")]
public FontFamily WritingFont { get; set; }
[Category("Writing")]
[DisplayName("Writing Font Size")]
[Description("This property uses the DoubleUpDown as the default editor.")]
public double WritingFontSize { get; set; }
[Category("Conections")]
[Description("This property is a complex property and has no default editor.")]
[ExpandableObject]
public Person Spouse { get; set; }
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.WritingFont = new FontFamily("Arial");
person.WritingFontSize = 12.5;
person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" };
return person;
}
}
} }
}
} }

129
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml

@ -1,68 +1,87 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="PropertyGrid" > Title="PropertyGrid" >
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The PropertyGrid control allows you inspect and edit properties of an object. This PropertyGrid allows you do autogenerate all properties or specify the specific properties you want to display. You can use the standard editors that are provided with the PropertyGrid or you can use custom editors that target a Type, specific properties, or both. The PropertyGrid also supports complex properties, which allows you to drill down into a nested property hierarchy."
TextWrapping="Wrap" />
<GroupBox Header="Features" Grid.Row="1" Margin="5">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="The PropertyGrid control allows you inspect and edit properties of an object. This PropertyGrid allows you do autogenerate all properties or specify the specific properties you want to display. You can use the standard editors that are provided with the PropertyGrid or you can use custom editors that target a Type, specific properties, or both. The PropertyGrid also supports complex properties, which allows you to drill down into a nested property hierarchy." <TextBlock Text="Display Sumary:" VerticalAlignment="Center" />
TextWrapping="Wrap" /> <CheckBox x:Name="_displaySummary" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Shows/Hides the summary panel of the PropertyGrid." />
<GroupBox Header="Features" Grid.Row="1" Margin="5" > <TextBlock Text="Filter:" VerticalAlignment="Center" Grid.Row="1" />
<Grid Margin="5"> <extToolkit:WatermarkTextBox x:Name="_filter"
<Grid.RowDefinitions> Grid.Row="1"
<RowDefinition Height="Auto" /> Grid.Column="1"
<RowDefinition Height="Auto" /> Watermark="Search"
</Grid.RowDefinitions> VerticalAlignment="Center" Margin="5" ToolTip="Filters the properties within the PropertyGrid." />
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Display Sumary:" VerticalAlignment="Center" /> <TextBlock Text="Is Categorized:" VerticalAlignment="Center" Grid.Column="2" />
<CheckBox x:Name="_displaySummary" Grid.Column="1" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Shows/Hides the summary panel of the PropertyGrid."/> <CheckBox x:Name="_isCategorized" Grid.Column="3" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Gets/Sets the layout of the PropertyGrid." />
<TextBlock Text="Filter:" VerticalAlignment="Center" Grid.Row="1" /> <TextBlock Text="Show Advanced Options:" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2" />
<extToolkit:WatermarkTextBox x:Name="_filter" Grid.Row="1" Grid.Column="1" <CheckBox x:Name="_showAdvancedOptions" Grid.Row="1" Grid.Column="3" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Shows/Hides the advanced options menu next to a property." />
Watermark="Search" </Grid>
VerticalAlignment="Center" Margin="5" ToolTip="Filters the properties within the PropertyGrid."/> </GroupBox>
<TextBlock Text="Is Categorized:" VerticalAlignment="Center" Grid.Column="2" /> <StackPanel Grid.Row="2" Margin="10">
<CheckBox x:Name="_isCategorized" Grid.Column="3" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Gets/Sets the layout of the PropertyGrid."/> <TextBlock Text="Usage:" Style="{StaticResource Header}" />
<TextBlock Text="To inspect an object simply set the PropertyGrid.SelectedObject property to an instance of the object you want to inspect."
TextWrapping="Wrap" />
<Grid Height="400" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Show Advanced Options:" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2" /> <Button x:Name="_button" Height="200" Width="200" Margin="25" HorizontalAlignment="Center" VerticalAlignment="Center">Inspect Me</Button>
<CheckBox x:Name="_showAdvancedOptions" Grid.Row="1" Grid.Column="3" IsChecked="True" VerticalAlignment="Center" Margin="5" ToolTip="Shows/Hides the advanced options menu next to a property."/>
</Grid>
</GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <extToolkit:PropertyGrid Grid.Column="1"
<TextBlock Text="Usage:" Style="{StaticResource Header}" /> DisplaySummary="{Binding IsChecked, ElementName=_displaySummary}"
<TextBlock Text="To inspect an object simply set the PropertyGrid.SelectedObject property to an instance of the object you want to inspect." Filter="{Binding Text, ElementName=_filter, Mode=TwoWay}"
TextWrapping="Wrap"/> IsCategorized="{Binding IsChecked, ElementName=_isCategorized, Mode=TwoWay}"
<Grid Height="400" Margin="10" > ShowAdvancedOptions="{Binding IsChecked, ElementName=_showAdvancedOptions}"
<Grid.ColumnDefinitions> SelectedObject="{Binding ElementName=_button}" />
<ColumnDefinition /> </Grid>
<ColumnDefinition Width="*" /> </StackPanel>
</Grid.ColumnDefinitions> </Grid>
<Button x:Name="_button" Height="200" Width="200" Margin="25" HorizontalAlignment="Center" VerticalAlignment="Center">Inspect Me</Button>
<extToolkit:PropertyGrid Grid.Column="1"
DisplaySummary="{Binding IsChecked, ElementName=_displaySummary}"
Filter="{Binding Text, ElementName=_filter, Mode=TwoWay}"
IsCategorized="{Binding IsChecked, ElementName=_isCategorized, Mode=TwoWay}"
ShowAdvancedOptions="{Binding IsChecked, ElementName=_showAdvancedOptions}"
SelectedObject="{Binding ElementName=_button}"/>
</Grid>
</StackPanel>
</Grid>
</infControls:DemoView> </infControls:DemoView>

38
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs

@ -1,17 +1,35 @@
using Microsoft.Practices.Prism.Regions; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls; using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml

@ -1,22 +1,40 @@
<TreeViewItem x:Class="Samples.Modules.PropertyGrid.Views.NavigationView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.PropertyGrid.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.PropertyGrid.Views" xmlns:views="clr-namespace:Samples.Modules.PropertyGrid.Views"
Header="PropertyGrid" Tag="{x:Type views:HomeView}"> Header="PropertyGrid" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
<TreeViewItem Header="Editors"> <TreeViewItem Header="Editors">
<TreeViewItem Header="Default Editors" Tag="{x:Type views:DefaultEditors}" /> <TreeViewItem Header="Default Editors" Tag="{x:Type views:DefaultEditors}" />
<TreeViewItem Header="Custom Editors" Tag="{x:Type views:CustomEditors}"/> <TreeViewItem Header="Custom Editors" Tag="{x:Type views:CustomEditors}" />
</TreeViewItem> </TreeViewItem>
<TreeViewItem Header="Properties"> <TreeViewItem Header="Properties">
<TreeViewItem Header="Binding to Structs" Tag="{x:Type views:BindingToStructs}"/> <TreeViewItem Header="Binding to Structs" Tag="{x:Type views:BindingToStructs}" />
<TreeViewItem Header="Expandable Properties" Tag="{x:Type views:ExpandableProperties}"/> <TreeViewItem Header="Expandable Properties" Tag="{x:Type views:ExpandableProperties}" />
<TreeViewItem Header="Providing an ItemsSource" Tag="{x:Type views:CustomItemsSource}"/> <TreeViewItem Header="Providing an ItemsSource" Tag="{x:Type views:CustomItemsSource}" />
<TreeViewItem Header="Specifying Properties" Tag="{x:Type views:SpecifyingProperties}"/> <TreeViewItem Header="Specifying Properties" Tag="{x:Type views:SpecifyingProperties}" />
</TreeViewItem> </TreeViewItem>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

76
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml

@ -1,30 +1,50 @@
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.SpecifyingProperties" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.PropertyGrid.Views.SpecifyingProperties"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Specifying Properties"> Title="Specifying Properties">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="By default the propertyGrid will autogenerate all the properties for a given object. You can override this behavior by setting the AutoGenerateProperties property to False, and then provide a collection of PropertyDefinitions of the properties you would like to show." <TextBlock Text="By default the propertyGrid will autogenerate all the properties for a given object. You can override this behavior by setting the AutoGenerateProperties property to False, and then provide a collection of PropertyDefinitions of the properties you would like to show."
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<StackPanel Grid.Row="1" Margin="10"> <StackPanel Grid.Row="1" Margin="10">
<TextBlock Text="Specifying Properties:" Style="{StaticResource Header}" /> <TextBlock Text="Specifying Properties:" Style="{StaticResource Header}" />
<extToolkit:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" <extToolkit:PropertyGrid x:Name="_propertyGrid"
AutoGenerateProperties="False"> Width="450"
<!-- Only the following properties will be displayed in the PropertyGrid --> Margin="10"
<extToolkit:PropertyGrid.PropertyDefinitions> AutoGenerateProperties="False">
<extToolkit:PropertyDefinition Name="FirstName" /> <!-- Only the following properties will be displayed in the PropertyGrid -->
<extToolkit:PropertyDefinition Name="FavoriteColor" /> <extToolkit:PropertyGrid.PropertyDefinitions>
<extToolkit:PropertyDefinition Name="PetNames" /> <extToolkit:PropertyDefinition Name="FirstName" />
</extToolkit:PropertyGrid.PropertyDefinitions> <extToolkit:PropertyDefinition Name="FavoriteColor" />
</extToolkit:PropertyGrid> <extToolkit:PropertyDefinition Name="PetNames" />
</StackPanel> </extToolkit:PropertyGrid.PropertyDefinitions>
</Grid> </extToolkit:PropertyGrid>
</infControls:DemoView> </StackPanel>
</Grid>
</infControls:DemoView>

264
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/SpecifyingProperties.xaml.cs

@ -1,106 +1,180 @@
using Samples.Infrastructure.Controls; /************************************************************************
using System.ComponentModel;
using System.Collections.Generic; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System; using System;
using System.Windows.Media; using System.Collections.Generic;
using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Media;
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.PropertyGrid.Views namespace Samples.Modules.PropertyGrid.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for SpecifyingProperties.xaml /// Interaction logic for SpecifyingProperties.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class SpecifyingProperties : DemoView public partial class SpecifyingProperties : DemoView
{
public SpecifyingProperties()
{ {
public SpecifyingProperties() InitializeComponent();
{ _propertyGrid.SelectedObject = Person.CreatePerson();
InitializeComponent(); }
_propertyGrid.SelectedObject = Person.CreatePerson();
} public class Person
{
[Category( "Information" )]
[DisplayName( "First Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string FirstName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Last Name" )]
[Description( "This property uses a TextBox as the default editor." )]
public string LastName
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Date of Birth" )]
[Description( "This property uses the DateTimeUpDown as the default editor." )]
public DateTime DateOfBirth
{
get;
set;
}
[DisplayName( "Grade Point Average" )]
[Description( "This property uses the DoubleUpDown as the default editor." )]
public double GradePointAvg
{
get;
set;
}
[Category( "Information" )]
[Description( "This property uses the IntegerUpDown as the default editor." )]
public int Age
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Is Male" )]
[Description( "This property uses a CheckBox as the default editor." )]
public bool IsMale
{
get;
set;
}
[Category( "Information" )]
[DisplayName( "Favorite Color" )]
[Description( "This property uses the ColorPicker as the default editor." )]
public Color FavoriteColor
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Hand" )]
[Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public HorizontalAlignment WritingHand
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font" )]
[Description( "This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values" )]
public FontFamily WritingFont
{
get;
set;
}
[Category( "Writing" )]
[DisplayName( "Writing Font Size" )]
[Description( "This property uses the DoubleUpDown as the default editor." )]
public double WritingFontSize
{
get;
set;
}
[Category( "Conections" )]
[DisplayName( "Pet Names" )]
[Description( "This property uses the PrimitiveTypeCollectionEditor as the default editor." )]
public List<String> PetNames
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property uses the CollectionEditor as the default editor." )]
public List<Person> Friends
{
get;
set;
}
[Category( "Conections" )]
[Description( "This property is a complex property and has no default editor." )]
public Person Spouse
{
get;
set;
}
public class Person public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime( 1975, 1, 23 );
person.Age = DateTime.Today.Year - person.DateOfBirth.Year;
person.GradePointAvg = 3.98;
person.IsMale = true;
person.FavoriteColor = Colors.Blue;
person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily( "Arial" );
person.WritingFontSize = 12.5;
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" };
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } };
person.Spouse = new Person()
{ {
[Category("Information")] FirstName = "Jane",
[DisplayName("First Name")] LastName = "Doe"
[Description("This property uses a TextBox as the default editor.")] };
public string FirstName { get; set; } return person;
}
[Category("Information")]
[DisplayName("Last Name")]
[Description("This property uses a TextBox as the default editor.")]
public string LastName { get; set; }
[Category("Information")]
[DisplayName("Date of Birth")]
[Description("This property uses the DateTimeUpDown as the default editor.")]
public DateTime DateOfBirth { get; set; }
[DisplayName("Grade Point Average")]
[Description("This property uses the DoubleUpDown as the default editor.")]
public double GradePointAvg { get; set; }
[Category("Information")]
[Description("This property uses the IntegerUpDown as the default editor.")]
public int Age { get; set; }
[Category("Information")]
[DisplayName("Is Male")]
[Description("This property uses a CheckBox as the default editor.")]
public bool IsMale { get; set; }
[Category("Information")]
[DisplayName("Favorite Color")]
[Description("This property uses the ColorPicker as the default editor.")]
public Color FavoriteColor { get; set; }
[Category("Writing")]
[DisplayName("Writing Hand")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")]
public HorizontalAlignment WritingHand { get; set; }
[Category("Writing")]
[DisplayName("Writing Font")]
[Description("This property uses a ComboBox as the default editor. The ComboBox is auto populated with the enum values")]
public FontFamily WritingFont { get; set; }
[Category("Writing")]
[DisplayName("Writing Font Size")]
[Description("This property uses the DoubleUpDown as the default editor.")]
public double WritingFontSize { get; set; }
[Category("Conections")]
[DisplayName("Pet Names")]
[Description("This property uses the PrimitiveTypeCollectionEditor as the default editor.")]
public List<String> PetNames { get; set; }
[Category("Conections")]
[Description("This property uses the CollectionEditor as the default editor.")]
public List<Person> Friends { get; set; }
[Category("Conections")]
[Description("This property is a complex property and has no default editor.")]
public Person Spouse { get; set; }
public static Person CreatePerson()
{
var person = new Person();
person.FirstName = "John";
person.LastName = "Doe";
person.DateOfBirth = new DateTime(1975, 1, 23);
person.Age = DateTime.Today.Year - person.DateOfBirth.Year;
person.GradePointAvg = 3.98;
person.IsMale = true;
person.FavoriteColor = Colors.Blue;
person.WritingHand = System.Windows.HorizontalAlignment.Right;
person.WritingFont = new FontFamily("Arial");
person.WritingFontSize = 12.5;
person.PetNames = new List<string>() { "Pet 1", "Pet 2", "Pet 3" };
person.Friends = new List<Person>() { new Person() { FirstName = "First", LastName = "Friend" }, new Person() { FirstName = "Second", LastName = "Friend" } };
person.Spouse = new Person() { FirstName = "Jane", LastName = "Doe" };
return person;
}
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Text")] [assembly: AssemblyTitle( "Samples.Modules.Text" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany( "Microsoft" )]
[assembly: AssemblyProduct("Samples.Modules.Text")] [assembly: AssemblyProduct( "Samples.Modules.Text" )]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

51
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/TextModule.cs

@ -1,26 +1,45 @@
using System; /************************************************************************
using Microsoft.Practices.Unity;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using Samples.Infrastructure; using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; using Samples.Infrastructure.Extensions;
using Samples.Modules.Text.Views; using Samples.Modules.Text.Views;
namespace Samples.Modules.Text namespace Samples.Modules.Text
{ {
public class TextModule: ModuleBase public class TextModule : ModuleBase
{
public TextModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public TextModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { } Container.RegisterNavigationType( typeof( WatermarkTextBoxView ) );
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
Container.RegisterNavigationType(typeof(WatermarkTextBoxView));
}
} }
}
} }

35
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/HomeView.xaml

@ -1,13 +1,34 @@
<infControls:DemoView x:Class="Samples.Modules.Text.Views.HomeView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Text.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Text Controls"> Title="Text Controls">
<Grid> <Grid>
<extToolkit:TokenizedTextBox x:Name="_textBox" <extToolkit:TokenizedTextBox x:Name="_textBox"
DisplayMemberPath="FullName" DisplayMemberPath="FullName"
SearchMemberPath="FirstName" SearchMemberPath="FirstName"
ValueMemberPath="Id" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" /> ValueMemberPath="Id"
</Grid> HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="250" />
</Grid>
</infControls:DemoView> </infControls:DemoView>

96
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/HomeView.xaml.cs

@ -1,42 +1,76 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
using Microsoft.Practices.Prism.Regions; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Text.Views namespace Samples.Modules.Text.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
_textBox.Text = "1;2;"; //is of object ids
_textBox.ItemsSource = new List<Email>()
{ {
InitializeComponent(); new Email() { Id = 1, FirstName = "John", LastName = "Doe", EmailAddress = "john@test.com" },
new Email() { Id = 2, FirstName = "Jane", LastName = "Doe", EmailAddress = "jane@test.com" },
_textBox.Text = "1;2;"; //is of object ids };
_textBox.ItemsSource = new List<Email>() }
{
new Email() { Id = 1, FirstName = "John", LastName = "Doe", EmailAddress = "john@test.com" }, public class Email
new Email() { Id = 2, FirstName = "Jane", LastName = "Doe", EmailAddress = "jane@test.com" }, {
}; public int Id
} {
get;
set;
}
public string FirstName
{
get;
set;
}
public string LastName
{
get;
set;
}
public string EmailAddress
{
get;
set;
}
public class Email public string FullName
{
get
{ {
public int Id { get; set; } return String.Format( "{0}, {1}", LastName, FirstName );
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string FullName
{
get
{
return String.Format("{0}, {1}", LastName, FirstName);
}
}
} }
}
} }
}
} }

40
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/NavigationView.xaml

@ -1,16 +1,34 @@
<TreeViewItem x:Class="Samples.Modules.Text.Views.NavigationView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Text.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.Text.Views" xmlns:views="clr-namespace:Samples.Modules.Text.Views"
Header="Text" Tag="{x:Type views:HomeView}"> Header="Text" Tag="{x:Type views:HomeView}">
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
<TreeViewItem Header="MaskedTextBox" /> <TreeViewItem Header="MaskedTextBox" />
<TreeViewItem Header="MultiLineTextEditor" /> <TreeViewItem Header="MultiLineTextEditor" />
<TreeViewItem Header="RichTextBox" /> <TreeViewItem Header="RichTextBox" />
<TreeViewItem Header="WatermarkTextBox" Tag="{x:Type views:WatermarkTextBoxView}" /> <TreeViewItem Header="WatermarkTextBox" Tag="{x:Type views:WatermarkTextBoxView}" />
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.Text.Views namespace Samples.Modules.Text.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

102
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/WatermarkTextBoxView.xaml

@ -1,48 +1,66 @@
<infControls:DemoView x:Class="Samples.Modules.Text.Views.WatermarkTextBoxView" <!--*********************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Text.Views.WatermarkTextBoxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure" xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="WatermarkTextBox"> Title="WatermarkTextBox">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*"/> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="The WatermarkTextBox is simply a TextBox that allows you to sepcify an object, usually a String, to represent null or missing text." /> <TextBlock Text="The WatermarkTextBox is simply a TextBox that allows you to sepcify an object, usually a String, to represent null or missing text." />
<GroupBox Header="Features" Grid.Row="1" > <GroupBox Header="Features" Grid.Row="1">
<Grid Margin="5"> <Grid Margin="5">
<CheckBox x:Name="_selectAll" Content="SelectAllOnGotFocus" VerticalAlignment="Center" Margin="5" ToolTip="Selects all text in the WatermarkTextBox when it receives focus." /> <CheckBox x:Name="_selectAll" Content="SelectAllOnGotFocus" VerticalAlignment="Center" Margin="5" ToolTip="Selects all text in the WatermarkTextBox when it receives focus." />
</Grid> </Grid>
</GroupBox> </GroupBox>
<StackPanel Grid.Row="2" Margin="10"> <StackPanel Grid.Row="2" Margin="10">
<TextBlock Text="Default:" Style="{StaticResource Header}" /> <TextBlock Text="Default:" Style="{StaticResource Header}" />
<extToolkit:WatermarkTextBox Grid.Column="1" Margin="5" MinWidth="200" Watermark="Enter Text" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}"/> <extToolkit:WatermarkTextBox Grid.Column="1" Margin="5" MinWidth="200" Watermark="Enter Text" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}" />
<TextBlock Text="Image Watermark:" Style="{StaticResource Header}" /> <TextBlock Text="Image Watermark:" Style="{StaticResource Header}" />
<extToolkit:WatermarkTextBox Grid.Column="1" Margin="5" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}" > <extToolkit:WatermarkTextBox Grid.Column="1" Margin="5" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}">
<extToolkit:WatermarkTextBox.Watermark> <extToolkit:WatermarkTextBox.Watermark>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="/Samples.Modules.Text;component/Images/PencilTool16.png" Stretch="None" /> <Image Source="/Samples.Modules.Text;component/Images/PencilTool16.png" Stretch="None" />
<TextBlock Text="Enter Text" Margin="4,0,0,0" /> <TextBlock Text="Enter Text" Margin="4,0,0,0" />
</StackPanel> </StackPanel>
</extToolkit:WatermarkTextBox.Watermark> </extToolkit:WatermarkTextBox.Watermark>
</extToolkit:WatermarkTextBox> </extToolkit:WatermarkTextBox>
<TextBlock Grid.Row="2" Text="Custom WatermarkTemplate:" Style="{StaticResource Header}" /> <TextBlock Grid.Row="2" Text="Custom WatermarkTemplate:" Style="{StaticResource Header}" />
<extToolkit:WatermarkTextBox Grid.Row="2" Grid.Column="1" Margin="5" Watermark="Enter Text" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}"> <extToolkit:WatermarkTextBox Grid.Row="2" Grid.Column="1" Margin="5" Watermark="Enter Text" SelectAllOnGotFocus="{Binding IsChecked, ElementName=_selectAll}">
<extToolkit:WatermarkTextBox.WatermarkTemplate> <extToolkit:WatermarkTextBox.WatermarkTemplate>
<DataTemplate> <DataTemplate>
<Border BorderBrush="Green" BorderThickness="1" Padding="5" > <Border BorderBrush="Green" BorderThickness="1" Padding="5">
<ContentControl Content="{Binding}" Foreground="DarkRed" FontWeight="Bold" Focusable="False" /> <ContentControl Content="{Binding}" Foreground="DarkRed" FontWeight="Bold" Focusable="False" />
</Border> </Border>
</DataTemplate> </DataTemplate>
</extToolkit:WatermarkTextBox.WatermarkTemplate> </extToolkit:WatermarkTextBox.WatermarkTemplate>
</extToolkit:WatermarkTextBox> </extToolkit:WatermarkTextBox>
</StackPanel> </StackPanel>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Text/Views/WatermarkTextBoxView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Text.Views namespace Samples.Modules.Text.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for WatermarkTextBoxView.xaml /// Interaction logic for WatermarkTextBoxView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive=false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class WatermarkTextBoxView : DemoView public partial class WatermarkTextBoxView : DemoView
{
public WatermarkTextBoxView()
{ {
public WatermarkTextBoxView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

52
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Properties/AssemblyInfo.cs

@ -1,25 +1,41 @@
using System.Reflection; /************************************************************************
using System.Resources;
using System.Runtime.CompilerServices; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Samples.Modules.Wizard")] [assembly: AssemblyTitle( "Samples.Modules.Wizard" )]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription( "" )]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany( "" )]
[assembly: AssemblyProduct("Samples.Modules.Wizard")] [assembly: AssemblyProduct( "Samples.Modules.Wizard" )]
[assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyCopyright( "Copyright © 2011" )]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture( "" )]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible( false )]
//In order to begin building localizable applications, set //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
@ -33,11 +49,11 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]
@ -51,5 +67,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion( "1.0.0.0" )]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion( "1.0.0.0" )]

50
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml

@ -1,24 +1,42 @@
<infControls:DemoView x:Class="Samples.Modules.Wizard.Views.HomeView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<infControls:DemoView x:Class="Samples.Modules.Wizard.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infControls="clr-namespace:Samples.Infrastructure.Controls;assembly=Samples.Infrastructure"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Title="Wizard"> Title="Wizard">
<Grid> <Grid>
<extToolkit:Wizard FinishButtonClosesWindow="True"> <extToolkit:Wizard FinishButtonClosesWindow="True">
<extToolkit:WizardPage x:Name="IntroPage" <extToolkit:WizardPage x:Name="IntroPage"
Title="Welcome to my Wizard" Title="Welcome to my Wizard"
Description="This Wizard will walk you though how to do something." /> Description="This Wizard will walk you though how to do something." />
<extToolkit:WizardPage x:Name="Page1" PageType="Interior" <extToolkit:WizardPage x:Name="Page1" PageType="Interior"
Title="Page 1" Title="Page 1"
Description="This is the first page in the process."/> Description="This is the first page in the process." />
<extToolkit:WizardPage x:Name="Page2" PageType="Interior" <extToolkit:WizardPage x:Name="Page2" PageType="Interior"
Title="Page 2" Title="Page 2"
Description="This is the second page in the process"/> Description="This is the second page in the process" />
<extToolkit:WizardPage x:Name="LastPage" PageType="Interior" <extToolkit:WizardPage x:Name="LastPage" PageType="Interior"
Title="Last Page" Title="Last Page"
Description="This is the last page in the process" Description="This is the last page in the process"
CanFinish="True"/> CanFinish="True" />
</extToolkit:Wizard> </extToolkit:Wizard>
</Grid> </Grid>
</infControls:DemoView> </infControls:DemoView>

39
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml.cs

@ -1,18 +1,35 @@
using System; /************************************************************************
using Samples.Infrastructure.Controls;
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Samples.Infrastructure.Controls;
namespace Samples.Modules.Wizard.Views namespace Samples.Modules.Wizard.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for HomeView.xaml /// Interaction logic for HomeView.xaml
/// </summary> /// </summary>
[RegionMemberLifetime(KeepAlive = false)] [RegionMemberLifetime( KeepAlive = false )]
public partial class HomeView : DemoView public partial class HomeView : DemoView
{
public HomeView()
{ {
public HomeView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

30
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/NavigationView.xaml

@ -1,11 +1,29 @@
<TreeViewItem x:Class="Samples.Modules.Wizard.Views.NavigationView" <!--*********************************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
********************************************************************-->
<TreeViewItem x:Class="Samples.Modules.Wizard.Views.NavigationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Samples.Modules.Wizard.Views" xmlns:views="clr-namespace:Samples.Modules.Wizard.Views"
Header="Wizard" Tag="{x:Type views:HomeView}" > Header="Wizard" Tag="{x:Type views:HomeView}" >
<TreeViewItem.Resources> <TreeViewItem.Resources>
<Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" /> <Style TargetType="views:NavigationView" BasedOn="{StaticResource {x:Type TreeViewItem}}" />
</TreeViewItem.Resources> </TreeViewItem.Resources>
</TreeViewItem> </TreeViewItem>

46
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/NavigationView.xaml.cs

@ -1,27 +1,33 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows; Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows.Controls; 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.Modules.Wizard.Views namespace Samples.Modules.Wizard.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for NavigationView.xaml /// Interaction logic for NavigationView.xaml
/// </summary> /// </summary>
public partial class NavigationView : TreeViewItem public partial class NavigationView : TreeViewItem
{
public NavigationView()
{ {
public NavigationView() InitializeComponent();
{
InitializeComponent();
}
} }
}
} }

51
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/WizardModule.cs

@ -1,25 +1,44 @@
using System; /************************************************************************
using Samples.Infrastructure;
using Samples.Infrastructure.Extensions; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using Microsoft.Practices.Prism.Regions; using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity; using Microsoft.Practices.Unity;
using Samples.Infrastructure;
using Samples.Infrastructure.Extensions;
using Samples.Modules.Wizard.Views; using Samples.Modules.Wizard.Views;
namespace Samples.Modules.Wizard namespace Samples.Modules.Wizard
{ {
public class WizardModule : ModuleBase public class WizardModule : ModuleBase
{
public WizardModule( IUnityContainer container, IRegionManager regionManager )
: base( container, regionManager )
{
}
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion( RegionNames.NavigationRegion, typeof( NavigationView ) );
}
protected override void RegisterViewsAndTypes()
{ {
public WizardModule(IUnityContainer container, IRegionManager regionManager) Container.RegisterNavigationType( typeof( HomeView ) );
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.NavigationRegion, typeof(NavigationView));
}
protected override void RegisterViewsAndTypes()
{
Container.RegisterNavigationType(typeof(HomeView));
}
} }
}
} }

56
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Commands/TreeViewCommandBehavior.cs

@ -1,26 +1,44 @@
using System; /************************************************************************
using Microsoft.Practices.Prism.Commands;
using System.Windows.Controls; Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.Prism.Commands;
namespace Samples.Infrastructure.Commands namespace Samples.Infrastructure.Commands
{ {
public class TreeViewCommandBehavior : CommandBehaviorBase<TreeView> public class TreeViewCommandBehavior : CommandBehaviorBase<TreeView>
{
public TreeViewCommandBehavior( TreeView treeView )
: base( treeView )
{
treeView.SelectedItemChanged += SelectedItemChanged;
}
void SelectedItemChanged( object sender, RoutedPropertyChangedEventArgs<object> e )
{ {
public TreeViewCommandBehavior(TreeView treeView) //This treeview command is specfic to the navigation region,
: base(treeView) //so I always want to pass the tag of the selected treeviewitem
{ //because it will conatin the Type of view to navigate to.
treeView.SelectedItemChanged += SelectedItemChanged; var type = ( e.NewValue as FrameworkElement ).Tag as Type;
} CommandParameter = type != null ? type.FullName : null;
ExecuteCommand();
void SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
//This treeview command is specfic to the navigation region,
//so I always want to pass the tag of the selected treeviewitem
//because it will conatin the Type of view to navigate to.
var type = (e.NewValue as FrameworkElement).Tag as Type;
CommandParameter = type != null ? type.FullName : null;
ExecuteCommand();
}
} }
}
} }

117
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Commands/TreeViewSelected.cs

@ -1,64 +1,81 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
namespace Samples.Infrastructure.Commands namespace Samples.Infrastructure.Commands
{ {
public class TreeViewSelected public class TreeViewSelected
{ {
private static readonly DependencyProperty SelectedCommandBehaviorProperty = DependencyProperty.RegisterAttached("SelectedCommandBehavior", typeof(TreeViewCommandBehavior), typeof(TreeViewSelected), null); private static readonly DependencyProperty SelectedCommandBehaviorProperty = DependencyProperty.RegisterAttached( "SelectedCommandBehavior", typeof( TreeViewCommandBehavior ), typeof( TreeViewSelected ), null );
public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(TreeViewSelected), new PropertyMetadata(OnSetCommandCallback)); public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached( "Command", typeof( ICommand ), typeof( TreeViewSelected ), new PropertyMetadata( OnSetCommandCallback ) );
public static void SetCommand(TreeView menuItem, ICommand command) public static void SetCommand( TreeView menuItem, ICommand command )
{ {
menuItem.SetValue(CommandProperty, command); menuItem.SetValue( CommandProperty, command );
} }
public static ICommand GetCommand(TreeView menuItem) public static ICommand GetCommand( TreeView menuItem )
{ {
return menuItem.GetValue(CommandProperty) as ICommand; return menuItem.GetValue( CommandProperty ) as ICommand;
} }
public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.RegisterAttached("CommandParameter", typeof(object), typeof(TreeViewSelected), new PropertyMetadata(OnSetCommandParameterCallback)); public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.RegisterAttached( "CommandParameter", typeof( object ), typeof( TreeViewSelected ), new PropertyMetadata( OnSetCommandParameterCallback ) );
public static void SetCommandParameter(TreeView menuItem, object parameter) public static void SetCommandParameter( TreeView menuItem, object parameter )
{ {
menuItem.SetValue(CommandParameterProperty, parameter); menuItem.SetValue( CommandParameterProperty, parameter );
} }
public static object GetCommandParameter(TreeView menuItem) public static object GetCommandParameter( TreeView menuItem )
{ {
return menuItem.GetValue(CommandParameterProperty); return menuItem.GetValue( CommandParameterProperty );
} }
private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) private static void OnSetCommandCallback( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e )
{ {
TreeView menuItem = dependencyObject as TreeView; TreeView menuItem = dependencyObject as TreeView;
if (menuItem != null) if( menuItem != null )
{ {
TreeViewCommandBehavior behavior = GetOrCreateBehavior(menuItem); TreeViewCommandBehavior behavior = GetOrCreateBehavior( menuItem );
behavior.Command = e.NewValue as ICommand; behavior.Command = e.NewValue as ICommand;
} }
} }
private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) private static void OnSetCommandParameterCallback( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e )
{ {
TreeView menuItem = dependencyObject as TreeView; TreeView menuItem = dependencyObject as TreeView;
if (menuItem != null) if( menuItem != null )
{ {
TreeViewCommandBehavior behavior = GetOrCreateBehavior(menuItem); TreeViewCommandBehavior behavior = GetOrCreateBehavior( menuItem );
behavior.CommandParameter = e.NewValue; behavior.CommandParameter = e.NewValue;
} }
} }
private static TreeViewCommandBehavior GetOrCreateBehavior(TreeView menuItem) private static TreeViewCommandBehavior GetOrCreateBehavior( TreeView menuItem )
{ {
TreeViewCommandBehavior behavior = menuItem.GetValue(SelectedCommandBehaviorProperty) as TreeViewCommandBehavior; TreeViewCommandBehavior behavior = menuItem.GetValue( SelectedCommandBehaviorProperty ) as TreeViewCommandBehavior;
if (behavior == null) if( behavior == null )
{ {
behavior = new TreeViewCommandBehavior(menuItem); behavior = new TreeViewCommandBehavior( menuItem );
menuItem.SetValue(SelectedCommandBehaviorProperty, behavior); menuItem.SetValue( SelectedCommandBehaviorProperty, behavior );
} }
return behavior; return behavior;
}
} }
}
} }

256
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Controls/DemoView.cs

@ -1,118 +1,154 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.IO;
namespace Samples.Infrastructure.Controls namespace Samples.Infrastructure.Controls
{ {
public class DemoView : ContentControl public class DemoView : ContentControl
{
#region Members
readonly string _applicationPath = String.Empty;
const string _samplesFolderName = "Samples";
#endregion //Members
#region Properties
public static readonly DependencyProperty CSharpTextProperty = DependencyProperty.Register( "CSharpText", typeof( string ), typeof( DemoView ), new UIPropertyMetadata( null ) );
public string CSharpText
{
get
{
return ( string )GetValue( CSharpTextProperty );
}
set
{
SetValue( CSharpTextProperty, value );
}
}
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( "Title", typeof( string ), typeof( DemoView ), new UIPropertyMetadata( null ) );
public string Title
{
get
{
return ( string )GetValue( TitleProperty );
}
set
{
SetValue( TitleProperty, value );
}
}
public static readonly DependencyProperty XamlTextProperty = DependencyProperty.Register( "XamlText", typeof( string ), typeof( DemoView ), new UIPropertyMetadata( null ) );
public string XamlText
{
get
{
return ( string )GetValue( XamlTextProperty );
}
set
{
SetValue( XamlTextProperty, value );
}
}
#endregion //Properties
#region Constructors
static DemoView()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( DemoView ), new FrameworkPropertyMetadata( typeof( DemoView ) ) );
}
public DemoView()
{ {
#region Members _applicationPath = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );
readonly string _applicationPath = String.Empty;
const string _samplesFolderName = "Samples";
#endregion //Members
#region Properties
public static readonly DependencyProperty CSharpTextProperty = DependencyProperty.Register("CSharpText", typeof(string), typeof(DemoView), new UIPropertyMetadata(null));
public string CSharpText
{
get { return (string)GetValue(CSharpTextProperty); }
set { SetValue(CSharpTextProperty, value); }
}
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(DemoView), new UIPropertyMetadata(null));
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
public static readonly DependencyProperty XamlTextProperty = DependencyProperty.Register("XamlText", typeof(string), typeof(DemoView), new UIPropertyMetadata(null));
public string XamlText
{
get { return (string)GetValue(XamlTextProperty); }
set { SetValue(XamlTextProperty, value); }
}
#endregion //Properties
#region Constructors
static DemoView()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DemoView), new FrameworkPropertyMetadata(typeof(DemoView)));
}
public DemoView()
{
_applicationPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
}
#endregion //Constructors
#region Base Class Overrides
protected override void OnContentChanged(object oldContent, object newContent)
{
base.OnContentChanged(oldContent, newContent);
//the parent of the content will be the View
ResolveContentCode((newContent as FrameworkElement).Parent);
}
#endregion //Base Class Overrides
#region Methods
private void ResolveContentCode(object newContent)
{
//get the type of the content loaded in the ContentRegion
var type = newContent.GetType();
//grab only the name of the content which will correspond to the name of the file to load
var viewName = type.FullName.Substring(type.FullName.LastIndexOf(".") + 1);
//get the module name
var moduleName = type.Module.Name.Replace(".dll", String.Empty);
SetText(viewName, moduleName);
}
private void SetText(string viewName, string moduleName)
{
SetCSharpText(viewName, moduleName);
SetXamlText(viewName, moduleName);
}
private void SetCSharpText(string viewName, string moduleName)
{
//now we need to append the file extension
string fileName = String.Format("{0}.xaml", viewName);
string filePath = GetFilePath(moduleName, fileName);
XamlText = ReadFileText(filePath);
}
private void SetXamlText(string viewName, string moduleName)
{
//now we need to append the file extension
string fileName = String.Format("{0}.xaml.cs", viewName);
string filePath = GetFilePath(moduleName, fileName);
CSharpText = ReadFileText(filePath);
}
private string GetFilePath(string moduleName, string fileName)
{
return Path.Combine(_applicationPath, _samplesFolderName, moduleName, fileName);
}
private static string ReadFileText(string filePath)
{
string text = String.Empty;
if (File.Exists(filePath))
text = File.ReadAllText(filePath);
return text;
}
#endregion //Methods
} }
#endregion //Constructors
#region Base Class Overrides
protected override void OnContentChanged( object oldContent, object newContent )
{
base.OnContentChanged( oldContent, newContent );
//the parent of the content will be the View
ResolveContentCode( ( newContent as FrameworkElement ).Parent );
}
#endregion //Base Class Overrides
#region Methods
private void ResolveContentCode( object newContent )
{
//get the type of the content loaded in the ContentRegion
var type = newContent.GetType();
//grab only the name of the content which will correspond to the name of the file to load
var viewName = type.FullName.Substring( type.FullName.LastIndexOf( "." ) + 1 );
//get the module name
var moduleName = type.Module.Name.Replace( ".dll", String.Empty );
SetText( viewName, moduleName );
}
private void SetText( string viewName, string moduleName )
{
SetCSharpText( viewName, moduleName );
SetXamlText( viewName, moduleName );
}
private void SetCSharpText( string viewName, string moduleName )
{
//now we need to append the file extension
string fileName = String.Format( "{0}.xaml", viewName );
string filePath = GetFilePath( moduleName, fileName );
XamlText = ReadFileText( filePath );
}
private void SetXamlText( string viewName, string moduleName )
{
//now we need to append the file extension
string fileName = String.Format( "{0}.xaml.cs", viewName );
string filePath = GetFilePath( moduleName, fileName );
CSharpText = ReadFileText( filePath );
}
private string GetFilePath( string moduleName, string fileName )
{
return Path.Combine( _applicationPath, _samplesFolderName, moduleName, fileName );
}
private static string ReadFileText( string filePath )
{
string text = String.Empty;
if( File.Exists( filePath ) )
text = File.ReadAllText( filePath );
return text;
}
#endregion //Methods
}
} }

83
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Converters/CSharpColorConverter.cs

@ -1,43 +1,58 @@
using System; /************************************************************************
using System.Collections.Generic;
using System.Linq; Extended WPF Toolkit
using System.Text;
using System.Windows.Data; Copyright (C) 2010-2012 Xceed Software Inc.
using Samples.Infrastructure.Core.CodeFormatting;
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using Samples.Infrastructure.Core.CodeFormatting;
namespace Samples.Infrastructure.Converters namespace Samples.Infrastructure.Converters
{ {
public class CSharpColorConverter : IValueConverter public class CSharpColorConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value == null )
return value;
String val = ( String )value;
CSharpFormat cSharpFormat = new CSharpFormat();
FlowDocument doc = new FlowDocument();
Paragraph p = new Paragraph();
p = cSharpFormat.FormatCode( val );
doc.Blocks.Add( p );
RichTextBox rtb = new RichTextBox();
rtb.IsReadOnly = true;
rtb.Document = doc;
rtb.Document.PageWidth = 2500.0;
rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.FontFamily = new FontFamily( "Courier New" );
return rtb;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{ {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) throw new NotImplementedException();
{
if (value == null)
return value;
String val = (String)value;
CSharpFormat cSharpFormat = new CSharpFormat();
FlowDocument doc = new FlowDocument();
Paragraph p = new Paragraph();
p = cSharpFormat.FormatCode(val);
doc.Blocks.Add(p);
RichTextBox rtb = new RichTextBox();
rtb.IsReadOnly = true;
rtb.Document = doc;
rtb.Document.PageWidth = 2500.0;
rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.FontFamily = new FontFamily("Courier New");
return rtb;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
} }
}
} }

240
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Converters/XamlColorConverter.cs

@ -1,121 +1,139 @@
using System; /************************************************************************
Extended WPF Toolkit
Copyright (C) 2010-2012 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Reciprocal
License (Ms-RL) as published at http://wpftoolkit.codeplex.com/license
This program can be provided to you by Xceed Software Inc. under a
proprietary commercial license agreement for use in non-Open Source
projects. The commercial version of Extended WPF Toolkit also includes
priority technical support, commercial updates, and many additional
useful WPF controls if you license Xceed Business Suite for WPF.
Visit http://xceed.com and follow @datagrid on Twitter.
**********************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Controls; using System.Windows.Media;
using Samples.Infrastructure.Core.CodeFormatting; using Samples.Infrastructure.Core.CodeFormatting;
namespace Samples.Infrastructure.Converters namespace Samples.Infrastructure.Converters
{ {
public class XamlColorConverter : IValueConverter public class XamlColorConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value == null )
return value;
string xaml = value as string;
FlowDocument doc = new FlowDocument();
ColorizeXAML( xaml, doc );
RichTextBox rtb = new RichTextBox();
rtb.IsReadOnly = true;
rtb.Document = doc;
rtb.Document.PageWidth = 2500.0;
rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.FontFamily = new FontFamily( "Courier New" );
return rtb;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
#region SyntaxColoring
#region ColorizeXAML
public void ColorizeXAML( string xamlText, FlowDocument targetDoc )
{
XmlTokenizer tokenizer = new XmlTokenizer();
XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement;
List<XmlToken> tokens = tokenizer.Tokenize( xamlText, ref mode );
List<string> tokenTexts = new List<string>( tokens.Count );
List<Color> colors = new List<Color>( tokens.Count );
int position = 0;
foreach( XmlToken token in tokens )
{
string tokenText = xamlText.Substring( position, token.Length );
tokenTexts.Add( tokenText );
Color color = ColorForToken( token, tokenText );
colors.Add( color );
position += token.Length;
}
Paragraph p = new Paragraph();
// Loop through tokens
for( int i = 0; i < tokenTexts.Count; i++ )
{
Run r = new Run( tokenTexts[ i ] );
r.Foreground = new SolidColorBrush( colors[ i ] );
p.Inlines.Add( r );
}
targetDoc.Blocks.Add( p );
}
#endregion //ColorizeXAML
static Color ColorForToken( XmlToken token, string tokenText )
{ {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) Color color = Color.FromRgb( 0, 0, 0 );
{ switch( token.Kind )
if (value == null) {
return value; case XmlTokenKind.Open:
case XmlTokenKind.OpenClose:
string xaml = value as string; case XmlTokenKind.Close:
case XmlTokenKind.SelfClose:
FlowDocument doc = new FlowDocument(); case XmlTokenKind.CommentBegin:
ColorizeXAML(xaml, doc); case XmlTokenKind.CommentEnd:
case XmlTokenKind.CDataBegin:
RichTextBox rtb = new RichTextBox(); case XmlTokenKind.CDataEnd:
rtb.IsReadOnly = true; case XmlTokenKind.Equals:
rtb.Document = doc; case XmlTokenKind.OpenProcessingInstruction:
rtb.Document.PageWidth = 2500.0; case XmlTokenKind.CloseProcessingInstruction:
rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; case XmlTokenKind.AttributeValue:
rtb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; color = Color.FromRgb( 0, 0, 255 );
rtb.FontFamily = new FontFamily("Courier New"); // color = "blue";
return rtb; break;
} case XmlTokenKind.ElementName:
color = Color.FromRgb( 163, 21, 21 );
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) // color = "brown";
{ break;
throw new NotImplementedException(); case XmlTokenKind.TextContent:
} // color = "black";
break;
#region SyntaxColoring case XmlTokenKind.AttributeName:
case XmlTokenKind.Entity:
#region ColorizeXAML color = Color.FromRgb( 255, 0, 0 );
// color = "red";
public void ColorizeXAML(string xamlText, FlowDocument targetDoc) break;
{ case XmlTokenKind.CommentText:
XmlTokenizer tokenizer = new XmlTokenizer(); color = Color.FromRgb( 0, 128, 0 );
XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement; // color = "green";
break;
List<XmlToken> tokens = tokenizer.Tokenize(xamlText, ref mode); }
List<string> tokenTexts = new List<string>(tokens.Count); if( token.Kind == XmlTokenKind.ElementWhitespace
List<Color> colors = new List<Color>(tokens.Count); || ( token.Kind == XmlTokenKind.TextContent && tokenText.Trim() == "" ) )
int position = 0; {
foreach (XmlToken token in tokens) // color = null;
{ }
string tokenText = xamlText.Substring(position, token.Length); return color;
tokenTexts.Add(tokenText);
Color color = ColorForToken(token, tokenText);
colors.Add(color);
position += token.Length;
}
Paragraph p = new Paragraph();
// Loop through tokens
for (int i = 0; i < tokenTexts.Count; i++)
{
Run r = new Run(tokenTexts[i]);
r.Foreground = new SolidColorBrush(colors[i]);
p.Inlines.Add(r);
}
targetDoc.Blocks.Add(p);
}
#endregion //ColorizeXAML
static Color ColorForToken(XmlToken token, string tokenText)
{
Color color = Color.FromRgb(0, 0, 0);
switch (token.Kind)
{
case XmlTokenKind.Open:
case XmlTokenKind.OpenClose:
case XmlTokenKind.Close:
case XmlTokenKind.SelfClose:
case XmlTokenKind.CommentBegin:
case XmlTokenKind.CommentEnd:
case XmlTokenKind.CDataBegin:
case XmlTokenKind.CDataEnd:
case XmlTokenKind.Equals:
case XmlTokenKind.OpenProcessingInstruction:
case XmlTokenKind.CloseProcessingInstruction:
case XmlTokenKind.AttributeValue:
color = Color.FromRgb(0, 0, 255);
// color = "blue";
break;
case XmlTokenKind.ElementName:
color = Color.FromRgb(163, 21, 21);
// color = "brown";
break;
case XmlTokenKind.TextContent:
// color = "black";
break;
case XmlTokenKind.AttributeName:
case XmlTokenKind.Entity:
color = Color.FromRgb(255, 0, 0);
// color = "red";
break;
case XmlTokenKind.CommentText:
color = Color.FromRgb(0, 128, 0);
// color = "green";
break;
}
if (token.Kind == XmlTokenKind.ElementWhitespace
|| (token.Kind == XmlTokenKind.TextContent && tokenText.Trim() == ""))
{
// color = null;
}
return color;
}
#endregion SyntaxColoring
} }
#endregion SyntaxColoring
}
} }

682
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Core/CodeFormatting/CSharpFormat.cs

@ -22,370 +22,418 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
namespace Samples.Infrastructure.Core.CodeFormatting namespace Samples.Infrastructure.Core.CodeFormatting
{ {
public class CSharpFormat : CLikeFormat public class CSharpFormat : CLikeFormat
{
/// <summary>
/// The list of C# keywords.
/// </summary>
protected override string Keywords
{ {
/// <summary> get
/// The list of C# keywords. {
/// </summary> return "abstract as base bool break byte case catch char "
protected override string Keywords + "checked class const continue decimal default delegate do double else "
{ + "enum event explicit extern false finally fixed float for foreach goto "
get + "if implicit in int interface internal is lock long namespace new null "
{ + "object operator out override partial params private protected public readonly "
return "abstract as base bool break byte case catch char " + "ref return sbyte sealed short sizeof stackalloc static string struct "
+ "checked class const continue decimal default delegate do double else " + "switch this throw true try typeof uint ulong unchecked unsafe ushort "
+ "enum event explicit extern false finally fixed float for foreach goto " + "using value virtual void volatile where while yield";
+ "if implicit in int interface internal is lock long namespace new null " }
+ "object operator out override partial params private protected public readonly "
+ "ref return sbyte sealed short sizeof stackalloc static string struct "
+ "switch this throw true try typeof uint ulong unchecked unsafe ushort "
+ "using value virtual void volatile where while yield";
}
}
/// <summary>
/// The list of C# preprocessors.
/// </summary>
protected override string Preprocessors
{
get
{
return "#if #else #elif #endif #define #undef #warning "
+ "#error #line #region #endregion #pragma";
}
}
} }
/// <summary> /// <summary>
/// Provides a base class for formatting languages similar to C. /// The list of C# preprocessors.
/// </summary> /// </summary>
public abstract class CLikeFormat : CodeFormat protected override string Preprocessors
{ {
/// <summary> get
/// Regular expression string to match single line and multi-line {
/// comments (// and /* */). return "#if #else #elif #endif #define #undef #warning "
/// </summary> + "#error #line #region #endregion #pragma";
protected override string CommentRegEx }
{
get { return @"/\*.*?\*/|//.*?(?=\r|\n)"; }
}
/// <summary>
/// Regular expression string to match string and character literals.
/// </summary>
protected override string StringRegEx
{
get { return @"@?""""|@?"".*?(?!\\).""|''|'.*?(?!\\).'"; }
}
} }
}
/// <summary>
/// Provides a base class for formatting languages similar to C.
/// </summary>
public abstract class CLikeFormat : CodeFormat
{
/// <summary> /// <summary>
/// Provides a base class for formatting most programming languages. /// Regular expression string to match single line and multi-line
/// comments (// and /* */).
/// </summary> /// </summary>
public abstract class CodeFormat : SourceFormat protected override string CommentRegEx
{ {
/// <summary> get
/// Must be overridden to provide a list of keywords defined in {
/// each language. return @"/\*.*?\*/|//.*?(?=\r|\n)";
/// </summary> }
/// <remarks> }
/// Keywords must be separated with spaces.
/// </remarks>
protected abstract string Keywords
{
get;
}
/// <summary>
/// Can be overridden to provide a list of preprocessors defined in
/// each language.
/// </summary>
/// <remarks>
/// Preprocessors must be separated with spaces.
/// </remarks>
protected virtual string Preprocessors
{
get { return ""; }
}
/// <summary> /// <summary>
/// Must be overridden to provide a regular expression string /// Regular expression string to match string and character literals.
/// to match strings literals. /// </summary>
/// </summary> protected override string StringRegEx
protected abstract string StringRegEx {
{ get
get; {
} return @"@?""""|@?"".*?(?!\\).""|''|'.*?(?!\\).'";
}
}
}
/// <summary> /// <summary>
/// Must be overridden to provide a regular expression string /// Provides a base class for formatting most programming languages.
/// to match comments. /// </summary>
/// </summary> public abstract class CodeFormat : SourceFormat
protected abstract string CommentRegEx {
{ /// <summary>
get; /// Must be overridden to provide a list of keywords defined in
} /// each language.
/// </summary>
/// <remarks>
/// Keywords must be separated with spaces.
/// </remarks>
protected abstract string Keywords
{
get;
}
/// <summary> /// <summary>
/// Determines if the language is case sensitive. /// Can be overridden to provide a list of preprocessors defined in
/// </summary> /// each language.
/// <value><b>true</b> if the language is case sensitive, <b>false</b> /// </summary>
/// otherwise. The default is true.</value> /// <remarks>
/// <remarks> /// Preprocessors must be separated with spaces.
/// A case-insensitive language formatter must override this /// </remarks>
/// property to return false. protected virtual string Preprocessors
/// </remarks> {
public virtual bool CaseSensitive get
{ {
get { return true; } return "";
} }
}
/// <summary/> /// <summary>
protected CodeFormat() /// Must be overridden to provide a regular expression string
{ /// to match strings literals.
//generate the keyword and preprocessor regexes from the keyword lists /// </summary>
Regex r; protected abstract string StringRegEx
r = new Regex(@"\w+|-\w+|#\w+|@@\w+|#(?:\\(?:s|w)(?:\*|\+)?\w+)+|@\\w\*+"); {
string regKeyword = r.Replace(Keywords, @"(?<=^|\W)$0(?=\W)"); get;
string regPreproc = r.Replace(Preprocessors, @"(?<=^|\s)$0(?=\s|$)"); }
r = new Regex(@" +");
regKeyword = r.Replace(regKeyword, @"|");
regPreproc = r.Replace(regPreproc, @"|");
if (regPreproc.Length == 0)
{
regPreproc = "(?!.*)_{37}(?<!.*)"; //use something quite impossible...
}
//build a master regex with capturing groups
StringBuilder regAll = new StringBuilder();
regAll.Append("(");
regAll.Append(CommentRegEx);
regAll.Append(")|(");
regAll.Append(StringRegEx);
if (regPreproc.Length > 0)
{
regAll.Append(")|(");
regAll.Append(regPreproc);
}
regAll.Append(")|(");
regAll.Append(regKeyword);
regAll.Append(")");
RegexOptions caseInsensitive = CaseSensitive ? 0 : RegexOptions.IgnoreCase;
CodeRegex = new Regex(regAll.ToString(), RegexOptions.Singleline | caseInsensitive);
CodeParagraphGlobal = new List<Run>();
}
/// <summary> /// <summary>
/// Called to evaluate the HTML fragment corresponding to each /// Must be overridden to provide a regular expression string
/// matching token in the code. /// to match comments.
/// </summary> /// </summary>
/// <param name="match">The <see cref="Match"/> resulting from a protected abstract string CommentRegEx
/// single regular expression match.</param> {
/// <returns>A string containing the HTML code fragment.</returns> get;
protected override string MatchEval(Match match) //protected override
{
if (match.Groups[1].Success) //comment
{
StringReader reader = new StringReader(match.ToString());
string line;
StringBuilder sb = new StringBuilder();
while ((line = reader.ReadLine()) != null)
{
Run r = new Run(line);
r.Foreground = new SolidColorBrush(Color.FromRgb(0, 128, 0));
CodeParagraphGlobal.Add(r);
}
return "::::::";
}
else if (match.Groups[2].Success) //string literal
{
Run r = new Run(match.ToString());
r.Foreground = new SolidColorBrush(Color.FromRgb(0, 96, 128));
CodeParagraphGlobal.Add(r);
return "::::::";
}
else if (match.Groups[3].Success) //preprocessor keyword
{
Run r = new Run(match.ToString());
r.Foreground = new SolidColorBrush(Color.FromRgb(204, 102, 51));
CodeParagraphGlobal.Add(r);
return "::::::";
}
else if (match.Groups[4].Success) //keyword
{
Run r = new Run(match.ToString());
r.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
CodeParagraphGlobal.Add(r);
return "::::::";
}
else
{
return "";
}
}
} }
/// <summary> /// <summary>
/// Provides a base implementation for all code formatters. /// Determines if the language is case sensitive.
/// </summary> /// </summary>
/// <value><b>true</b> if the language is case sensitive, <b>false</b>
/// otherwise. The default is true.</value>
/// <remarks> /// <remarks>
/// <para> /// A case-insensitive language formatter must override this
/// To display the formatted code on your web site, the web page must /// property to return false.
/// refer to a stylesheet that defines the formatting for the different
/// CSS classes generated by CSharpFormat:
/// .csharpcode, pre, .rem, .kwrd, .str, .op, .preproc, .alt, .lnum.
/// </para>
/// <para>
/// Note that if you have multi-line comments in your source code
/// (like /* ... */), the "line numbers" or "alternate line background"
/// options will generate code that is not strictly HTML 4.01 compliant.
/// The code will still look good with IE5+ or Mozilla 0.8+.
/// </para>
/// </remarks> /// </remarks>
public abstract class SourceFormat public virtual bool CaseSensitive
{ {
/// <summary/> get
protected SourceFormat() {
{ return true;
_tabSpaces = 4; }
_lineNumbers = false; }
_alternate = false;
_embedStyleSheet = false;
}
private byte _tabSpaces; /// <summary/>
protected CodeFormat()
{
//generate the keyword and preprocessor regexes from the keyword lists
Regex r;
r = new Regex( @"\w+|-\w+|#\w+|@@\w+|#(?:\\(?:s|w)(?:\*|\+)?\w+)+|@\\w\*+" );
string regKeyword = r.Replace( Keywords, @"(?<=^|\W)$0(?=\W)" );
string regPreproc = r.Replace( Preprocessors, @"(?<=^|\s)$0(?=\s|$)" );
r = new Regex( @" +" );
regKeyword = r.Replace( regKeyword, @"|" );
regPreproc = r.Replace( regPreproc, @"|" );
if( regPreproc.Length == 0 )
{
regPreproc = "(?!.*)_{37}(?<!.*)"; //use something quite impossible...
}
//build a master regex with capturing groups
StringBuilder regAll = new StringBuilder();
regAll.Append( "(" );
regAll.Append( CommentRegEx );
regAll.Append( ")|(" );
regAll.Append( StringRegEx );
if( regPreproc.Length > 0 )
{
regAll.Append( ")|(" );
regAll.Append( regPreproc );
}
regAll.Append( ")|(" );
regAll.Append( regKeyword );
regAll.Append( ")" );
RegexOptions caseInsensitive = CaseSensitive ? 0 : RegexOptions.IgnoreCase;
CodeRegex = new Regex( regAll.ToString(), RegexOptions.Singleline | caseInsensitive );
CodeParagraphGlobal = new List<Run>();
}
/// <summary> /// <summary>
/// Gets or sets the tabs width. /// Called to evaluate the HTML fragment corresponding to each
/// </summary> /// matching token in the code.
/// <value>The number of space characters to substitute for tab /// </summary>
/// characters. The default is <b>4</b>, unless overridden is a /// <param name="match">The <see cref="Match"/> resulting from a
/// derived class.</value> /// single regular expression match.</param>
public byte TabSpaces /// <returns>A string containing the HTML code fragment.</returns>
protected override string MatchEval( Match match ) //protected override
{
if( match.Groups[ 1 ].Success ) //comment
{
StringReader reader = new StringReader( match.ToString() );
string line;
StringBuilder sb = new StringBuilder();
while( ( line = reader.ReadLine() ) != null )
{ {
get { return _tabSpaces; } Run r = new Run( line );
set { _tabSpaces = value; } r.Foreground = new SolidColorBrush( Color.FromRgb( 0, 128, 0 ) );
CodeParagraphGlobal.Add( r );
} }
return "::::::";
}
else if( match.Groups[ 2 ].Success ) //string literal
{
Run r = new Run( match.ToString() );
r.Foreground = new SolidColorBrush( Color.FromRgb( 0, 96, 128 ) );
CodeParagraphGlobal.Add( r );
return "::::::";
}
else if( match.Groups[ 3 ].Success ) //preprocessor keyword
{
Run r = new Run( match.ToString() );
r.Foreground = new SolidColorBrush( Color.FromRgb( 204, 102, 51 ) );
CodeParagraphGlobal.Add( r );
return "::::::";
}
else if( match.Groups[ 4 ].Success ) //keyword
{
Run r = new Run( match.ToString() );
r.Foreground = new SolidColorBrush( Color.FromRgb( 0, 0, 255 ) );
CodeParagraphGlobal.Add( r );
return "::::::";
}
else
{
return "";
}
}
}
/// <summary>
/// Provides a base implementation for all code formatters.
/// </summary>
/// <remarks>
/// <para>
/// To display the formatted code on your web site, the web page must
/// refer to a stylesheet that defines the formatting for the different
/// CSS classes generated by CSharpFormat:
/// .csharpcode, pre, .rem, .kwrd, .str, .op, .preproc, .alt, .lnum.
/// </para>
/// <para>
/// Note that if you have multi-line comments in your source code
/// (like /* ... */), the "line numbers" or "alternate line background"
/// options will generate code that is not strictly HTML 4.01 compliant.
/// The code will still look good with IE5+ or Mozilla 0.8+.
/// </para>
/// </remarks>
public abstract class SourceFormat
{
/// <summary/>
protected SourceFormat()
{
_tabSpaces = 4;
_lineNumbers = false;
_alternate = false;
_embedStyleSheet = false;
}
private bool _lineNumbers; private byte _tabSpaces;
/// <summary> /// <summary>
/// Enables or disables line numbers in output. /// Gets or sets the tabs width.
/// </summary> /// </summary>
/// <value>When <b>true</b>, line numbers are generated. /// <value>The number of space characters to substitute for tab
/// The default is <b>false</b>.</value> /// characters. The default is <b>4</b>, unless overridden is a
public bool LineNumbers /// derived class.</value>
{ public byte TabSpaces
get { return _lineNumbers; } {
set { _lineNumbers = value; } get
} {
return _tabSpaces;
}
set
{
_tabSpaces = value;
}
}
private bool _alternate; private bool _lineNumbers;
/// <summary> /// <summary>
/// Enables or disables alternating line background. /// Enables or disables line numbers in output.
/// </summary> /// </summary>
/// <value>When <b>true</b>, lines background is alternated. /// <value>When <b>true</b>, line numbers are generated.
/// The default is <b>false</b>.</value> /// The default is <b>false</b>.</value>
public bool Alternate public bool LineNumbers
{ {
get { return _alternate; } get
set { _alternate = value; } {
} return _lineNumbers;
}
set
{
_lineNumbers = value;
}
}
private bool _embedStyleSheet; private bool _alternate;
/// <summary> /// <summary>
/// Enables or disables the embedded CSS style sheet. /// Enables or disables alternating line background.
/// </summary> /// </summary>
/// <value>When <b>true</b>, the CSS &lt;style&gt; element is included /// <value>When <b>true</b>, lines background is alternated.
/// in the HTML output. The default is <b>false</b>.</value> /// The default is <b>false</b>.</value>
public bool EmbedStyleSheet public bool Alternate
{ {
get { return _embedStyleSheet; } get
set { _embedStyleSheet = value; } {
} return _alternate;
}
set
{
_alternate = value;
}
}
/// <summary> private bool _embedStyleSheet;
/// Transforms a source code string to HTML 4.01.
/// </summary>
/// <returns>A string containing the HTML formatted code.</returns>
public Paragraph FormatCode(string source)
{
return FormatCode(source, _lineNumbers, _alternate, _embedStyleSheet, false);
}
private Regex codeRegex; /// <summary>
/// Enables or disables the embedded CSS style sheet.
/// </summary>
/// <value>When <b>true</b>, the CSS &lt;style&gt; element is included
/// in the HTML output. The default is <b>false</b>.</value>
public bool EmbedStyleSheet
{
get
{
return _embedStyleSheet;
}
set
{
_embedStyleSheet = value;
}
}
/// <summary> /// <summary>
/// The regular expression used to capture language tokens. /// Transforms a source code string to HTML 4.01.
/// </summary> /// </summary>
protected Regex CodeRegex /// <returns>A string containing the HTML formatted code.</returns>
{ public Paragraph FormatCode( string source )
get { return codeRegex; } {
set { codeRegex = value; } return FormatCode( source, _lineNumbers, _alternate, _embedStyleSheet, false );
} }
private List<Run> codeParagraphGlobal; private Regex codeRegex;
/// <summary>
/// This is a List of Run's that can be added later to the string of code
/// </summary>
protected List<Run> CodeParagraphGlobal
{
get { return codeParagraphGlobal; }
set { codeParagraphGlobal = value; }
}
/// <summary> /// <summary>
/// Called to evaluate the HTML fragment corresponding to each /// The regular expression used to capture language tokens.
/// matching token in the code. /// </summary>
/// </summary> protected Regex CodeRegex
/// <param name="match">The <see cref="Match"/> resulting from a {
/// single regular expression match.</param> get
/// <returns>A string containing the HTML code fragment.</returns> {
protected abstract string MatchEval(Match match); //protected abstract return codeRegex;
}
//does the formatting job set
private Paragraph FormatCode(string source, bool lineNumbers, {
bool alternate, bool embedStyleSheet, bool subCode) codeRegex = value;
}
}
private List<Run> codeParagraphGlobal;
/// <summary>
/// This is a List of Run's that can be added later to the string of code
/// </summary>
protected List<Run> CodeParagraphGlobal
{
get
{
return codeParagraphGlobal;
}
set
{
codeParagraphGlobal = value;
}
}
/// <summary>
/// Called to evaluate the HTML fragment corresponding to each
/// matching token in the code.
/// </summary>
/// <param name="match">The <see cref="Match"/> resulting from a
/// single regular expression match.</param>
/// <returns>A string containing the HTML code fragment.</returns>
protected abstract string MatchEval( Match match ); //protected abstract
//does the formatting job
private Paragraph FormatCode( string source, bool lineNumbers,
bool alternate, bool embedStyleSheet, bool subCode )
{
Paragraph codeParagraph = new Paragraph();
//replace special characters
StringBuilder sb = new StringBuilder( source );
//color the code
source = codeRegex.Replace( sb.ToString(), new MatchEvaluator( this.MatchEval ) );
//codeRegex.Replace(
string[] characters = { "::::::" };
string[] split = source.Split( characters, new StringSplitOptions() );
int currentChunk = 0;
foreach( string code in split )
{
currentChunk++;
Run r = new Run( code );
codeParagraph.Inlines.Add( r );
if( ( currentChunk - 1 ) < codeParagraphGlobal.Count )
{ {
Paragraph codeParagraph = new Paragraph(); codeParagraph.Inlines.Add( codeParagraphGlobal[ currentChunk - 1 ] );
//replace special characters
StringBuilder sb = new StringBuilder(source);
//color the code
source = codeRegex.Replace(sb.ToString(), new MatchEvaluator(this.MatchEval));
//codeRegex.Replace(
string[] characters = { "::::::" };
string[] split = source.Split(characters, new StringSplitOptions());
int currentChunk = 0;
foreach (string code in split)
{
currentChunk++;
Run r = new Run(code);
codeParagraph.Inlines.Add(r);
if ((currentChunk - 1) < codeParagraphGlobal.Count)
{
codeParagraph.Inlines.Add(codeParagraphGlobal[currentChunk - 1]);
}
}
return codeParagraph;
} }
}
return codeParagraph;
} }
}
} }

663
ExtendedWPFToolkitSolution/Src/Samples/Samples.Infrastructure/Core/CodeFormatting/XamlFormat.cs

@ -1,351 +1,350 @@
//Author: Nick Kramer [MSFT] //Author: Nick Kramer [MSFT]
//Source: http://blogs.msdn.com/b/nickkramer/archive/2006/09/22/766934.aspx //Source: http://blogs.msdn.com/b/nickkramer/archive/2006/09/22/766934.aspx
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
namespace Samples.Infrastructure.Core.CodeFormatting namespace Samples.Infrastructure.Core.CodeFormatting
{ {
// XML tokenizer, tokens are designed to match Visual Studio syntax highlighting // XML tokenizer, tokens are designed to match Visual Studio syntax highlighting
class XmlTokenizer class XmlTokenizer
{
private string input;
private int position = 0;
private XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement;
public static List<XmlToken> Tokenize( string input )
{ {
private string input; XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement;
private int position = 0; XmlTokenizer tokenizer = new XmlTokenizer();
private XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement; return tokenizer.Tokenize( input, ref mode );
public static List<XmlToken> Tokenize(string input) }
{ public List<XmlToken> Tokenize( string input, ref XmlTokenizerMode _mode )
XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement; {
XmlTokenizer tokenizer = new XmlTokenizer(); this.input = input;
return tokenizer.Tokenize(input, ref mode); this.mode = _mode;
} this.position = 0;
public List<XmlToken> Tokenize(string input, ref XmlTokenizerMode _mode) List<XmlToken> result = Tokenize();
{ _mode = this.mode;
this.input = input; return result;
this.mode = _mode; }
this.position = 0; private List<XmlToken> Tokenize()
List<XmlToken> result = Tokenize(); {
_mode = this.mode; List<XmlToken> list = new List<XmlToken>();
return result; XmlToken token;
} do
private List<XmlToken> Tokenize() {
{ int previousPosition = position;
List<XmlToken> list = new List<XmlToken>(); token = NextToken();
XmlToken token; string tokenText = input.Substring( previousPosition, token.Length );
do list.Add( token );
{ }
int previousPosition = position; while( token.Kind != XmlTokenKind.EOF );
token = NextToken(); List<string> strings = TokensToStrings( list, input );
string tokenText = input.Substring(previousPosition, token.Length); return list;
list.Add(token); }
} private List<string> TokensToStrings( List<XmlToken> list, string input )
while (token.Kind != XmlTokenKind.EOF); {
List<string> strings = TokensToStrings(list, input); List<string> output = new List<string>();
return list; int position = 0;
} foreach( XmlToken token in list )
private List<string> TokensToStrings(List<XmlToken> list, string input) {
{ output.Add( input.Substring( position, token.Length ) );
List<string> output = new List<string>(); position += token.Length;
int position = 0; }
foreach (XmlToken token in list) return output;
{ }
output.Add(input.Substring(position, token.Length)); // debugging function
position += token.Length; public string RemainingText
} {
return output; get
} {
// debugging function return input.Substring( position );
public string RemainingText }
{ }
get private XmlToken NextToken()
{ {
return input.Substring(position); if( position >= input.Length )
} return new XmlToken( XmlTokenKind.EOF, 0 );
} XmlToken token;
private XmlToken NextToken() switch( mode )
{ {
if (position >= input.Length) case XmlTokenizerMode.AfterAttributeEquals:
return new XmlToken(XmlTokenKind.EOF, 0); token = TokenizeAttributeValue();
XmlToken token; break;
switch (mode) case XmlTokenizerMode.AfterAttributeName:
{ token = TokenizeSimple( "=", XmlTokenKind.Equals, XmlTokenizerMode.AfterAttributeEquals );
case XmlTokenizerMode.AfterAttributeEquals: break;
token = TokenizeAttributeValue(); case XmlTokenizerMode.AfterOpen:
break; token = TokenizeName( XmlTokenKind.ElementName, XmlTokenizerMode.InsideElement );
case XmlTokenizerMode.AfterAttributeName: break;
token = TokenizeSimple("=", XmlTokenKind.Equals, XmlTokenizerMode.AfterAttributeEquals); case XmlTokenizerMode.InsideCData:
break; token = TokenizeInsideCData();
case XmlTokenizerMode.AfterOpen: break;
token = TokenizeName(XmlTokenKind.ElementName, XmlTokenizerMode.InsideElement); case XmlTokenizerMode.InsideComment:
break; token = TokenizeInsideComment();
case XmlTokenizerMode.InsideCData: break;
token = TokenizeInsideCData(); case XmlTokenizerMode.InsideElement:
break; token = TokenizeInsideElement();
case XmlTokenizerMode.InsideComment: break;
token = TokenizeInsideComment(); case XmlTokenizerMode.InsideProcessingInstruction:
break; token = TokenizeInsideProcessingInstruction();
case XmlTokenizerMode.InsideElement: break;
token = TokenizeInsideElement(); case XmlTokenizerMode.OutsideElement:
break; token = TokenizeOutsideElement();
case XmlTokenizerMode.InsideProcessingInstruction: break;
token = TokenizeInsideProcessingInstruction(); default:
break; token = new XmlToken( XmlTokenKind.EOF, 0 );
case XmlTokenizerMode.OutsideElement: Debug.Fail( "missing case" );
token = TokenizeOutsideElement(); break;
break; }
default: return token;
token = new XmlToken(XmlTokenKind.EOF, 0); }
Debug.Fail("missing case"); private bool IsNameCharacter( char character )
break; {
} // XML rule: Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
return token; bool result = char.IsLetterOrDigit( character ) || character == '.' | character == '-' | character == '_' | character == ':';
} return result;
private bool IsNameCharacter(char character) }
{ private XmlToken TokenizeAttributeValue()
// XML rule: Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender {
bool result = char.IsLetterOrDigit(character) || character == '.' | character == '-' | character == '_' | character == ':'; Debug.Assert( mode == XmlTokenizerMode.AfterAttributeEquals );
return result; int closePosition = input.IndexOf( input[ position ], position + 1 );
} XmlToken token = new XmlToken( XmlTokenKind.AttributeValue, closePosition + 1 - position );
private XmlToken TokenizeAttributeValue() position = closePosition + 1;
{ mode = XmlTokenizerMode.InsideElement;
Debug.Assert(mode == XmlTokenizerMode.AfterAttributeEquals); return token;
int closePosition = input.IndexOf(input[position], position + 1); }
XmlToken token = new XmlToken(XmlTokenKind.AttributeValue, closePosition + 1 - position); private XmlToken TokenizeName( XmlTokenKind kind, XmlTokenizerMode nextMode )
position = closePosition + 1; {
mode = XmlTokenizerMode.InsideElement; Debug.Assert( mode == XmlTokenizerMode.AfterOpen || mode == XmlTokenizerMode.InsideElement );
return token; int i;
} for( i = position; i < input.Length; i++ )
private XmlToken TokenizeName(XmlTokenKind kind, XmlTokenizerMode nextMode) if( !IsNameCharacter( input[ i ] ) )
{ break;
Debug.Assert(mode == XmlTokenizerMode.AfterOpen || mode == XmlTokenizerMode.InsideElement); XmlToken token = new XmlToken( kind, i - position );
int i; mode = nextMode;
for (i = position; i < input.Length; i++) position = i;
if (!IsNameCharacter(input[i])) return token;
break; }
XmlToken token = new XmlToken(kind, i - position); private XmlToken TokenizeElementWhitespace()
mode = nextMode; {
position = i; int i;
return token; for( i = position; i < input.Length; i++ )
} if( !char.IsWhiteSpace( input[ i ] ) )
private XmlToken TokenizeElementWhitespace() break;
{ XmlToken token = new XmlToken( XmlTokenKind.ElementWhitespace, i - position );
int i; position = i;
for (i = position; i < input.Length; i++) return token;
if (!char.IsWhiteSpace(input[i])) }
break; private bool StartsWith( string text )
XmlToken token = new XmlToken(XmlTokenKind.ElementWhitespace, i - position); {
position = i; if( position + text.Length > input.Length )
return token; return false;
} else
private bool StartsWith(string text) return input.Substring( position, text.Length ) == text;
{ }
if (position + text.Length > input.Length) private XmlToken TokenizeInsideElement()
return false; {
else if( char.IsWhiteSpace( input[ position ] ) )
return input.Substring(position, text.Length) == text; return TokenizeElementWhitespace();
} else
private XmlToken TokenizeInsideElement() if( StartsWith( "/>" ) )
{ return TokenizeSimple( "/>", XmlTokenKind.SelfClose, XmlTokenizerMode.OutsideElement );
if (char.IsWhiteSpace(input[position])) else
return TokenizeElementWhitespace(); if( StartsWith( ">" ) )
else return TokenizeSimple( ">", XmlTokenKind.Close, XmlTokenizerMode.OutsideElement );
if (StartsWith("/>")) else
return TokenizeSimple("/>", XmlTokenKind.SelfClose, XmlTokenizerMode.OutsideElement); return TokenizeName( XmlTokenKind.AttributeName, XmlTokenizerMode.AfterAttributeName );
else }
if (StartsWith(">")) private XmlToken TokenizeText()
return TokenizeSimple(">", XmlTokenKind.Close, XmlTokenizerMode.OutsideElement); {
else Debug.Assert( input[ position ] != '<' );
return TokenizeName(XmlTokenKind.AttributeName, XmlTokenizerMode.AfterAttributeName); Debug.Assert( input[ position ] != '&' );
} Debug.Assert( mode == XmlTokenizerMode.OutsideElement );
private XmlToken TokenizeText() int i;
{ for( i = position; i < input.Length; i++ )
Debug.Assert(input[position] != '<'); if( input[ i ] == '<' || input[ i ] == '&' )
Debug.Assert(input[position] != '&'); break;
Debug.Assert(mode == XmlTokenizerMode.OutsideElement); XmlToken token = new XmlToken( XmlTokenKind.TextContent, i - position );
int i; position = i;
for (i = position; i < input.Length; i++) return token;
if (input[i] == '<' || input[i] == '&') }
break; private XmlToken TokenizeOutsideElement()
XmlToken token = new XmlToken(XmlTokenKind.TextContent, i - position); {
position = i; Debug.Assert( mode == XmlTokenizerMode.OutsideElement );
return token; if( position >= input.Length )
} return new XmlToken( XmlTokenKind.EOF, 0 );
private XmlToken TokenizeOutsideElement() switch( input[ position ] )
{ {
Debug.Assert(mode == XmlTokenizerMode.OutsideElement); case '<':
if (position >= input.Length) return TokenizeOpen();
return new XmlToken(XmlTokenKind.EOF, 0); case '&':
switch (input[position]) return TokenizeEntity();
{ default:
case '<': return TokenizeText();
return TokenizeOpen(); }
case '&': }
return TokenizeEntity(); private XmlToken TokenizeSimple( string text, XmlTokenKind kind, XmlTokenizerMode nextMode )
default: {
return TokenizeText(); XmlToken token = new XmlToken( kind, text.Length );
} position += text.Length;
} mode = nextMode;
private XmlToken TokenizeSimple(string text, XmlTokenKind kind, XmlTokenizerMode nextMode) return token;
{ }
XmlToken token = new XmlToken(kind, text.Length); private XmlToken TokenizeOpen()
position += text.Length; {
mode = nextMode; Debug.Assert( input[ position ] == '<' );
return token; if( StartsWith( "<!--" ) )
} return TokenizeSimple( "<!--", XmlTokenKind.CommentBegin, XmlTokenizerMode.InsideComment );
private XmlToken TokenizeOpen() else
{ if( StartsWith( "<![CDATA[" ) )
Debug.Assert(input[position] == '<'); return TokenizeSimple( "<![CDATA[", XmlTokenKind.CDataBegin, XmlTokenizerMode.InsideCData );
if (StartsWith("<!--")) else
return TokenizeSimple("<!--", XmlTokenKind.CommentBegin, XmlTokenizerMode.InsideComment); if( StartsWith( "<?" ) )
else return TokenizeSimple( "<?", XmlTokenKind.OpenProcessingInstruction, XmlTokenizerMode.InsideProcessingInstruction );
if (StartsWith("<![CDATA[")) else
return TokenizeSimple("<![CDATA[", XmlTokenKind.CDataBegin, XmlTokenizerMode.InsideCData); if( StartsWith( "</" ) )
else return TokenizeSimple( "</", XmlTokenKind.OpenClose, XmlTokenizerMode.AfterOpen );
if (StartsWith("<?"))
return TokenizeSimple("<?", XmlTokenKind.OpenProcessingInstruction, XmlTokenizerMode.InsideProcessingInstruction);
else
if (StartsWith("</"))
return TokenizeSimple("</", XmlTokenKind.OpenClose, XmlTokenizerMode.AfterOpen);
else
return TokenizeSimple("<", XmlTokenKind.Open, XmlTokenizerMode.AfterOpen);
}
private XmlToken TokenizeEntity()
{
Debug.Assert(mode == XmlTokenizerMode.OutsideElement);
Debug.Assert(input[position] == '&');
XmlToken token = new XmlToken(XmlTokenKind.Entity, input.IndexOf(';', position) - position);
position += token.Length;
return token;
}
private XmlToken TokenizeInsideProcessingInstruction()
{
Debug.Assert(mode == XmlTokenizerMode.InsideProcessingInstruction);
int tokenend = input.IndexOf("?>", position);
if (position == tokenend)
{
position += "?>".Length;
mode = XmlTokenizerMode.OutsideElement;
return new XmlToken(XmlTokenKind.CloseProcessingInstruction, "?>".Length);
}
else
{
XmlToken token = new XmlToken(XmlTokenKind.TextContent, tokenend - position);
position = tokenend;
return token;
}
}
private XmlToken TokenizeInsideCData()
{
Debug.Assert(mode == XmlTokenizerMode.InsideCData);
int tokenend = input.IndexOf("]]>", position);
if (position == tokenend)
{
position += "]]>".Length;
mode = XmlTokenizerMode.OutsideElement;
return new XmlToken(XmlTokenKind.CDataEnd, "]]>".Length);
}
else
{
XmlToken token = new XmlToken(XmlTokenKind.TextContent, tokenend - position);
position = tokenend;
return token;
}
}
private XmlToken TokenizeInsideComment()
{
Debug.Assert(mode == XmlTokenizerMode.InsideComment);
int tokenend = input.IndexOf("-->", position);
if (position == tokenend)
{
position += "-->".Length;
mode = XmlTokenizerMode.OutsideElement;
return new XmlToken(XmlTokenKind.CommentEnd, "-->".Length);
}
else else
{ return TokenizeSimple( "<", XmlTokenKind.Open, XmlTokenizerMode.AfterOpen );
XmlToken token = new XmlToken(XmlTokenKind.CommentText, tokenend - position);
position = tokenend;
return token;
}
}
} }
private XmlToken TokenizeEntity()
// Used so you can restart the tokenizer for the next line of XML
enum XmlTokenizerMode
{ {
InsideComment, Debug.Assert( mode == XmlTokenizerMode.OutsideElement );
InsideProcessingInstruction, Debug.Assert( input[ position ] == '&' );
AfterOpen, XmlToken token = new XmlToken( XmlTokenKind.Entity, input.IndexOf( ';', position ) - position );
AfterAttributeName, position += token.Length;
AfterAttributeEquals, return token;
InsideElement,
// after element name, before attribute or />
OutsideElement,
InsideCData
} }
private XmlToken TokenizeInsideProcessingInstruction()
struct XmlToken {
Debug.Assert( mode == XmlTokenizerMode.InsideProcessingInstruction );
int tokenend = input.IndexOf( "?>", position );
if( position == tokenend )
{
position += "?>".Length;
mode = XmlTokenizerMode.OutsideElement;
return new XmlToken( XmlTokenKind.CloseProcessingInstruction, "?>".Length );
}
else
{
XmlToken token = new XmlToken( XmlTokenKind.TextContent, tokenend - position );
position = tokenend;
return token;
}
}
private XmlToken TokenizeInsideCData()
{
Debug.Assert( mode == XmlTokenizerMode.InsideCData );
int tokenend = input.IndexOf( "]]>", position );
if( position == tokenend )
{
position += "]]>".Length;
mode = XmlTokenizerMode.OutsideElement;
return new XmlToken( XmlTokenKind.CDataEnd, "]]>".Length );
}
else
{
XmlToken token = new XmlToken( XmlTokenKind.TextContent, tokenend - position );
position = tokenend;
return token;
}
}
private XmlToken TokenizeInsideComment()
{ {
public XmlTokenKind Kind; Debug.Assert( mode == XmlTokenizerMode.InsideComment );
public short Length; int tokenend = input.IndexOf( "-->", position );
public XmlToken(XmlTokenKind kind, int length) if( position == tokenend )
{ {
Kind = kind; position += "-->".Length;
Length = (short)length; mode = XmlTokenizerMode.OutsideElement;
} return new XmlToken( XmlTokenKind.CommentEnd, "-->".Length );
}
else
{
XmlToken token = new XmlToken( XmlTokenKind.CommentText, tokenend - position );
position = tokenend;
return token;
}
} }
}
/* // Used so you can restart the tokenizer for the next line of XML
* this file implements a mostly correct XML tokenizer. The token boundaries enum XmlTokenizerMode
* have been chosen to match Visual Studio syntax highlighting, so a few of {
* the boundaries are little weird. (Especially comments) known issues: InsideComment,
* InsideProcessingInstruction,
* Doesn't handle DTD's AfterOpen,
* mediocre handling of processing instructions <? ?> -- it won't crash, AfterAttributeName,
* but the token boundaries are wrong AfterAttributeEquals,
* Doesn't enforce correct XML InsideElement,
* there's probably a few cases where it will die if given in valid XML // after element name, before attribute or />
* OutsideElement,
* InsideCData
* This tokenizer has been designed to be restartable, so you can tokenize }
* one line of XML at a time.
*/ struct XmlToken
enum XmlTokenKind {
public XmlTokenKind Kind;
public short Length;
public XmlToken( XmlTokenKind kind, int length )
{ {
Open, Kind = kind;
// < Length = ( short )length;
Close,
//>
SelfClose,
// />
OpenClose,
// </
ElementName,
ElementWhitespace,
//whitespace between attributes
AttributeName,
Equals,
// inside attribute
AttributeValue,
// attribute value
CommentBegin,
// <!--
CommentText,
CommentEnd,
// -->
Entity,
// &gt;
OpenProcessingInstruction,
// <?
CloseProcessingInstruction,
// ?>
CDataBegin,
// <![CDATA[
CDataEnd,
// ]]>
TextContent,
//WhitespaceContent, // text content that's whitespace. Space is embedded inside
EOF,
// end of file
} }
}
/*
* this file implements a mostly correct XML tokenizer. The token boundaries
* have been chosen to match Visual Studio syntax highlighting, so a few of
* the boundaries are little weird. (Especially comments) known issues:
*
* Doesn't handle DTD's
* mediocre handling of processing instructions <? ?> -- it won't crash,
* but the token boundaries are wrong
* Doesn't enforce correct XML
* there's probably a few cases where it will die if given in valid XML
*
*
* This tokenizer has been designed to be restartable, so you can tokenize
* one line of XML at a time.
*/
enum XmlTokenKind
{
Open,
// <
Close,
//>
SelfClose,
// />
OpenClose,
// </
ElementName,
ElementWhitespace,
//whitespace between attributes
AttributeName,
Equals,
// inside attribute
AttributeValue,
// attribute value
CommentBegin,
// <!--
CommentText,
CommentEnd,
// -->
Entity,
// &gt;
OpenProcessingInstruction,
// <?
CloseProcessingInstruction,
// ?>
CDataBegin,
// <![CDATA[
CDataEnd,
// ]]>
TextContent,
//WhitespaceContent, // text content that's whitespace. Space is embedded inside
EOF,
// end of file
}
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save