From 54fdc2c07201945d3712347c2e0c1a830cb258a3 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Fri, 29 Jul 2011 22:46:26 +0000 Subject: [PATCH] Wizard: Implemented Wizard Pages, Help, Back, Next buttons. Added features to set visibility of buttons from the Wizard and then override the behavior from the individual wizard pages. No styling yet. It's pretty plain. --- .../Views/HomeView.xaml | 23 +- .../Views/HomeView.xaml.cs | 98 +++++++ .../Views/HomeView.xaml | 7 +- .../Views/HomeView.xaml.cs | 2 + .../Views/HomeView.xaml | 14 +- .../Views/HomeView.xaml.cs | 79 ++++++ .../Views/HomeView.xaml | 22 +- .../Src/Samples/Samples/App.xaml.cs | 8 + .../WizardPageButtonVisibilityConverter.cs | 40 +++ .../WPFToolkit.Extended.csproj | 2 + .../Wizard/Implementation/Wizard.cs | 246 ++++++++++++++++-- .../Wizard/Implementation/WizardPage.cs | 40 ++- .../WizardPageButtonVisibility.cs | 12 + .../Wizard/Themes/Generic.xaml | 75 +++++- 14 files changed, 611 insertions(+), 57 deletions(-) create mode 100644 ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/WizardPageButtonVisibilityConverter.cs create mode 100644 ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPageButtonVisibility.cs diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml index b82e6c2a..e6c2d22b 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml @@ -1,6 +1,7 @@  - + - + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml.cs index e274dfd6..2a5303a6 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml.cs @@ -11,6 +11,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.ComponentModel; +using System.Collections.ObjectModel; namespace Samples.Modules.Button.Views { @@ -22,6 +24,102 @@ namespace Samples.Modules.Button.Views public HomeView() { InitializeComponent(); + DataContext = new MyViewModel(); + } + } + + public class Item + { + public bool IsChecked { get; set; } + public string Name { get; set; } + + public Item() + { + + } + } + public class MyViewModel : INotifyPropertyChanged + { + public ICommand MyCommand { get; private set; } + + private int _clickCount; + public int ClickCount + { + get { return _clickCount; } + set + { + _clickCount = value; + OnPropertyChanged("ClickCount"); + } + } + + private ObservableCollection _items; + public ObservableCollection Items + { + get { return _items; } + set + { + _items = value; + OnPropertyChanged("Items"); + } + } + + + public MyViewModel() + { + MyCommand = new CustomCommand(Execute, CanExecute); + + Items = new ObservableCollection(); + for (int i = 0; i < 10; i++) + { + Items.Add(new Item() { IsChecked = i % 2 == 0, Name = String.Format("Item {0}", i) }); + } + } + + private void Execute(object param) + { + ClickCount++; + //MessageBox.Show(String.Format("Executed {0}", param)); + } + + private bool CanExecute(object param) + { + return Convert.ToInt32(param) != 5; + } + + public event PropertyChangedEventHandler PropertyChanged; + protected void OnPropertyChanged(string propertyName) + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public class CustomCommand : ICommand + { + Action _execute; + Func _canExecute; + + public CustomCommand(Action execute, Func canExecute) + { + _execute = execute; + _canExecute = canExecute; + } + + public bool CanExecute(object parameter) + { + return _canExecute.Invoke(parameter); + } + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + + public void Execute(object parameter) + { + _execute(parameter); } } } diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml index 1afdee3e..ebcca33d 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml @@ -1,11 +1,8 @@  + xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"> - + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs index 3ba282e1..8381f6b9 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs @@ -11,6 +11,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Threading; +using System.Globalization; namespace Samples.Modules.DateTime.Views { diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml index 90d8f569..719033d4 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml @@ -4,8 +4,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="300" d:DesignWidth="300" xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"> - + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs index 64fb8750..073675a8 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs @@ -22,6 +22,85 @@ namespace Samples.Modules.PropertyGrid.Views public HomeView() { InitializeComponent(); + _listBox.Items.Add(new Data() { Name = "Item One" }); + _listBox.Items.Add(new Data() { Name = "Item Two" }); + } + } + + public class Data + { + private List _pages = new List(); + public List Pages + { + get { return _pages; } + set + { + _pages = value; + } + } + + private string _name; + public string Name + { + get { return _name; } + set + { + _name = value; + } + } + + private bool? _isLate; + public bool? IsLate + { + get { return _isLate; } + set + { + _isLate = value; + } + } + + private DateTime? _datOfBirth; + public DateTime? DatOfBirth + { + get { return _datOfBirth; } + set + { + _datOfBirth = value; + } + } + + public Data() + { + Pages.Add(new Person() { FirstName = "One" }); + Pages.Add(new Person() { FirstName = "Two" }); + } + } + + public class Person + { + private string _firstName; + public string FirstName + { + get { return _firstName; } + set + { + _firstName = value; + } + } + + private string _lastName; + public string LastName + { + get { return _lastName; } + set + { + _lastName = value; + } + } + + public Person() + { + } } } diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml index 1e6fd79f..6e541801 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml +++ b/ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml @@ -1,11 +1,23 @@  + xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"> - + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Samples/Samples/App.xaml.cs b/ExtendedWPFToolkitSolution/Src/Samples/Samples/App.xaml.cs index 19ffa829..43df21d2 100644 --- a/ExtendedWPFToolkitSolution/Src/Samples/Samples/App.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Samples/Samples/App.xaml.cs @@ -4,6 +4,8 @@ using System.Configuration; using System.Data; using System.Linq; using System.Windows; +using System.Globalization; +using System.Threading; namespace Samples { @@ -14,6 +16,12 @@ namespace Samples { protected override void OnStartup(StartupEventArgs e) { + // Put the following code before InitializeComponent() + // Sets the culture to French (France) + Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK"); + // Sets the UI culture to French (France) + Thread.CurrentThread.CurrentUICulture = new CultureInfo("da-DK"); + base.OnStartup(e); Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.Run(); diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/WizardPageButtonVisibilityConverter.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/WizardPageButtonVisibilityConverter.cs new file mode 100644 index 00000000..a0589d60 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/WizardPageButtonVisibilityConverter.cs @@ -0,0 +1,40 @@ +using System; +using System.Windows.Data; +using System.Windows; + +namespace Microsoft.Windows.Controls.Core.Converters +{ + public class WizardPageButtonVisibilityConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + Visibility wizardVisibility = (Visibility)values[0]; + WizardPageButtonVisibility wizardPageVisibility = (WizardPageButtonVisibility)values[1]; + + Visibility visibility = Visibility.Visible; + + switch (wizardPageVisibility) + { + case WizardPageButtonVisibility.Inherit: + visibility = wizardVisibility; + break; + case WizardPageButtonVisibility.Collapsed: + visibility = Visibility.Collapsed; + break; + case WizardPageButtonVisibility.Hidden: + visibility = Visibility.Hidden; + break; + case WizardPageButtonVisibility.Visible: + visibility = Visibility.Visible; + break; + } + + return visibility; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj index adacb2eb..958cf276 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -180,6 +180,7 @@ + @@ -274,6 +275,7 @@ + ResXFileCodeGenerator Resources.Designer.cs diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs index 092e705b..9c97a017 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs @@ -2,11 +2,110 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Data; namespace Microsoft.Windows.Controls { public class Wizard : ItemsControl { + #region Properties + + public static readonly DependencyProperty BackButtonContentProperty = DependencyProperty.Register("BackButtonContent", typeof(object), typeof(Wizard), new UIPropertyMetadata("Back")); + public object BackButtonContent + { + get { return (object)GetValue(BackButtonContentProperty); } + set { SetValue(BackButtonContentProperty, value); } + } + + public static readonly DependencyProperty BackButtonVisibilityProperty = DependencyProperty.Register("BackButtonVisibility", typeof(Visibility), typeof(Wizard), new UIPropertyMetadata(Visibility.Visible)); + public Visibility BackButtonVisibility + { + get { return (Visibility)GetValue(BackButtonVisibilityProperty); } + set { SetValue(BackButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty CancelButtonContentProperty = DependencyProperty.Register("CancelButtonContent", typeof(object), typeof(Wizard), new UIPropertyMetadata("Cancel")); + public object CancelButtonContent + { + get { return (object)GetValue(CancelButtonContentProperty); } + set { SetValue(CancelButtonContentProperty, value); } + } + + public static readonly DependencyProperty CancelButtonVisibilityProperty = DependencyProperty.Register("CancelButtonVisibility", typeof(Visibility), typeof(Wizard), new UIPropertyMetadata(Visibility.Visible)); + public Visibility CancelButtonVisibility + { + get { return (Visibility)GetValue(CancelButtonVisibilityProperty); } + set { SetValue(CancelButtonVisibilityProperty, value); } + } + + #region CurrentPage + + public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register("CurrentPage", typeof(WizardPage), typeof(Wizard), new UIPropertyMetadata(null, OnCurrentPageChanged)); + public WizardPage CurrentPage + { + get { return (WizardPage)GetValue(CurrentPageProperty); } + set { SetValue(CurrentPageProperty, value); } + } + + private static void OnCurrentPageChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + Wizard wizard = o as Wizard; + if (wizard != null) + wizard.OnCurrentPageChanged((WizardPage)e.OldValue, (WizardPage)e.NewValue); + } + + protected virtual void OnCurrentPageChanged(WizardPage oldValue, WizardPage newValue) + { + RaiseRoutedEvent(Wizard.PageChangedEvent); + } + + #endregion //CurrentPage + + public static readonly DependencyProperty FinishButtonContentProperty = DependencyProperty.Register("FinishButtonContent", typeof(object), typeof(Wizard), new UIPropertyMetadata("Finish")); + public object FinishButtonContent + { + get { return (object)GetValue(FinishButtonContentProperty); } + set { SetValue(FinishButtonContentProperty, value); } + } + + public static readonly DependencyProperty FinishButtonVisibilityProperty = DependencyProperty.Register("FinishButtonVisibility", typeof(Visibility), typeof(Wizard), new UIPropertyMetadata(Visibility.Visible)); + public Visibility FinishButtonVisibility + { + get { return (Visibility)GetValue(FinishButtonVisibilityProperty); } + set { SetValue(FinishButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty HelpButtonContentProperty = DependencyProperty.Register("HelpButtonContent", typeof(object), typeof(Wizard), new UIPropertyMetadata("Help")); + public object HelpButtonContent + { + get { return (object)GetValue(HelpButtonContentProperty); } + set { SetValue(HelpButtonContentProperty, value); } + } + + public static readonly DependencyProperty HelpButtonVisibilityProperty = DependencyProperty.Register("HelpButtonVisibility", typeof(Visibility), typeof(Wizard), new UIPropertyMetadata(Visibility.Visible)); + public Visibility HelpButtonVisibility + { + get { return (Visibility)GetValue(HelpButtonVisibilityProperty); } + set { SetValue(HelpButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty NextButtonContentProperty = DependencyProperty.Register("NextButtonContent", typeof(object), typeof(Wizard), new UIPropertyMetadata("Next")); + public object NextButtonContent + { + get { return (object)GetValue(NextButtonContentProperty); } + set { SetValue(NextButtonContentProperty, value); } + } + + public static readonly DependencyProperty NextButtonVisibilityProperty = DependencyProperty.Register("NextButtonVisibility", typeof(Visibility), typeof(Wizard), new UIPropertyMetadata(Visibility.Visible)); + public Visibility NextButtonVisibility + { + get { return (Visibility)GetValue(NextButtonVisibilityProperty); } + set { SetValue(NextButtonVisibilityProperty, value); } + } + + #endregion //Properties + #region Constructors static Wizard() @@ -16,12 +115,11 @@ namespace Microsoft.Windows.Controls public Wizard() { - CommandBindings.Add(new CommandBinding(WizardCommands.Cancel, Cancel, CanCancel)); - CommandBindings.Add(new CommandBinding(WizardCommands.Finish, Finish, CanFinish)); - CommandBindings.Add(new CommandBinding(WizardCommands.Help, Help, CanHelp)); + CommandBindings.Add(new CommandBinding(WizardCommands.Cancel, CancelWizard, CanCancelWizard)); + CommandBindings.Add(new CommandBinding(WizardCommands.Finish, FinishWizard, CanFinishWizard)); + CommandBindings.Add(new CommandBinding(WizardCommands.Help, RequestHelp, CanRequestHelp)); CommandBindings.Add(new CommandBinding(WizardCommands.NextPage, SelectNextPage, CanSelectNextPage)); CommandBindings.Add(new CommandBinding(WizardCommands.PreviousPage, SelectPreviousPage, CanSelectPreviousPage)); - CommandBindings.Add(new CommandBinding(WizardCommands.SelectPage, SelectPage, CanSelectPage)); } #endregion //Constructors @@ -38,70 +136,166 @@ namespace Microsoft.Windows.Controls return (item is WizardPage); } + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + if (Items.Count > 0 && CurrentPage == null) + CurrentPage = Items[0] as WizardPage; + } + #endregion //Base Class Overrides #region Commands - private void Cancel(object sender, ExecutedRoutedEventArgs e) + private void CancelWizard(object sender, ExecutedRoutedEventArgs e) { - throw new NotImplementedException(); + RaiseRoutedEvent(Wizard.CancelEvent); } - private void CanCancel(object sender, CanExecuteRoutedEventArgs e) + private void CanCancelWizard(object sender, CanExecuteRoutedEventArgs e) { - throw new NotImplementedException(); + e.CanExecute = false; } - private void Finish(object sender, ExecutedRoutedEventArgs e) + private void FinishWizard(object sender, ExecutedRoutedEventArgs e) { - throw new NotImplementedException(); + RaiseRoutedEvent(Wizard.FinishEvent); } - private void CanFinish(object sender, CanExecuteRoutedEventArgs e) + private void CanFinishWizard(object sender, CanExecuteRoutedEventArgs e) { - throw new NotImplementedException(); + e.CanExecute = false; } - private void Help(object sender, ExecutedRoutedEventArgs e) + private void RequestHelp(object sender, ExecutedRoutedEventArgs e) { - throw new NotImplementedException(); + RaiseRoutedEvent(Wizard.HelpEvent); } - private void CanHelp(object sender, CanExecuteRoutedEventArgs e) + private void CanRequestHelp(object sender, CanExecuteRoutedEventArgs e) { - throw new NotImplementedException(); + e.CanExecute = false; } private void SelectNextPage(object sender, ExecutedRoutedEventArgs e) { - throw new NotImplementedException(); + WizardPage nextPage = null; + + if (CurrentPage != null) + { + //check next page + if (CurrentPage.NextPage != null) + nextPage = CurrentPage.NextPage; + else + { + //no next page defined use index + var currentIndex = Items.IndexOf(CurrentPage); + var nextPageIndex = currentIndex + 1; + if (nextPageIndex < Items.Count) + nextPage = Items[nextPageIndex] as WizardPage; + } + } + + CurrentPage = nextPage; } private void CanSelectNextPage(object sender, CanExecuteRoutedEventArgs e) { - throw new NotImplementedException(); + if (CurrentPage != null) + { + if (CurrentPage.NextPage != null) + e.CanExecute = true; + else + { + var currentIndex = Items.IndexOf(CurrentPage); + var nextPageIndex = currentIndex + 1; + if (nextPageIndex < Items.Count) + e.CanExecute = true; + } + } } private void SelectPreviousPage(object sender, ExecutedRoutedEventArgs e) { - throw new NotImplementedException(); + WizardPage previousPage = null; + + if (CurrentPage != null) + { + //check previous page + if (CurrentPage.PreviousPage != null) + previousPage = CurrentPage.PreviousPage; + else + { + //no previous page defined so use index + var currentIndex = Items.IndexOf(CurrentPage); + var previousPageIndex = currentIndex - 1; + if (previousPageIndex > 0 && previousPageIndex < Items.Count) + previousPage = Items[previousPageIndex] as WizardPage; + } + } + + CurrentPage = previousPage; } private void CanSelectPreviousPage(object sender, CanExecuteRoutedEventArgs e) { - throw new NotImplementedException(); + if (CurrentPage != null) + { + if (CurrentPage.PreviousPage != null) + e.CanExecute = true; + else + { + var currentIndex = Items.IndexOf(CurrentPage); + var previousPageIndex = currentIndex - 1; + if (previousPageIndex > 0 && previousPageIndex < Items.Count) + e.CanExecute = true; + } + } + } + + #endregion //Commands + + #region Events + + public static readonly RoutedEvent CancelEvent = EventManager.RegisterRoutedEvent("Cancel", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Wizard)); + public event RoutedEventHandler Cancel + { + add { AddHandler(CancelEvent, value); } + remove { RemoveHandler(CancelEvent, value); } } - private void SelectPage(object sender, ExecutedRoutedEventArgs e) + public static readonly RoutedEvent PageChangedEvent = EventManager.RegisterRoutedEvent("PageChanged", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Wizard)); + public event RoutedEventHandler PageChanged { - throw new NotImplementedException(); + add { AddHandler(PageChangedEvent, value); } + remove { RemoveHandler(PageChangedEvent, value); } } - private void CanSelectPage(object sender, CanExecuteRoutedEventArgs e) + public static readonly RoutedEvent FinishEvent = EventManager.RegisterRoutedEvent("Finish", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Wizard)); + public event RoutedEventHandler Finish { - throw new NotImplementedException(); + add { AddHandler(FinishEvent, value); } + remove { RemoveHandler(FinishEvent, value); } } - #endregion //Commands + public static readonly RoutedEvent HelpEvent = EventManager.RegisterRoutedEvent("Help", RoutingStrategy.Bubble, typeof(EventHandler), typeof(Wizard)); + public event RoutedEventHandler Help + { + add { AddHandler(HelpEvent, value); } + remove { RemoveHandler(HelpEvent, value); } + } + + #endregion //Events + + #region Methods + + private void RaiseRoutedEvent(RoutedEvent routedEvent) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(routedEvent, this); + base.RaiseEvent(newEventArgs); + } + + #endregion //Methods } -} +} \ No newline at end of file diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPage.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPage.cs index fdfda10e..398232ec 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPage.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPage.cs @@ -8,11 +8,18 @@ namespace Microsoft.Windows.Controls { #region Properties - public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(WizardPage)); - public string Caption + public static readonly DependencyProperty BackButtonVisibilityProperty = DependencyProperty.Register("BackButtonVisibility", typeof(WizardPageButtonVisibility), typeof(WizardPage), new UIPropertyMetadata(WizardPageButtonVisibility.Inherit)); + public WizardPageButtonVisibility BackButtonVisibility { - get { return (string)base.GetValue(CaptionProperty); } - set { base.SetValue(CaptionProperty, value); } + get { return (WizardPageButtonVisibility)GetValue(BackButtonVisibilityProperty); } + set { SetValue(BackButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty CancelButtonVisibilityProperty = DependencyProperty.Register("CancelButtonVisibility", typeof(WizardPageButtonVisibility), typeof(WizardPage), new UIPropertyMetadata(WizardPageButtonVisibility.Inherit)); + public WizardPageButtonVisibility CancelButtonVisibility + { + get { return (WizardPageButtonVisibility)GetValue(CancelButtonVisibilityProperty); } + set { SetValue(CancelButtonVisibilityProperty, value); } } public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(WizardPage)); @@ -22,6 +29,27 @@ namespace Microsoft.Windows.Controls set { base.SetValue(DescriptionProperty, value); } } + public static readonly DependencyProperty FinishButtonVisibilityProperty = DependencyProperty.Register("FinishButtonVisibility", typeof(WizardPageButtonVisibility), typeof(WizardPage), new UIPropertyMetadata(WizardPageButtonVisibility.Inherit)); + public WizardPageButtonVisibility FinishButtonVisibility + { + get { return (WizardPageButtonVisibility)GetValue(FinishButtonVisibilityProperty); } + set { SetValue(FinishButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty HelpButtonVisibilityProperty = DependencyProperty.Register("HelpButtonVisibility", typeof(WizardPageButtonVisibility), typeof(WizardPage), new UIPropertyMetadata(WizardPageButtonVisibility.Inherit)); + public WizardPageButtonVisibility HelpButtonVisibility + { + get { return (WizardPageButtonVisibility)GetValue(HelpButtonVisibilityProperty); } + set { SetValue(HelpButtonVisibilityProperty, value); } + } + + public static readonly DependencyProperty NextButtonVisibilityProperty = DependencyProperty.Register("NextButtonVisibility", typeof(WizardPageButtonVisibility), typeof(WizardPage), new UIPropertyMetadata(WizardPageButtonVisibility.Inherit)); + public WizardPageButtonVisibility NextButtonVisibility + { + get { return (WizardPageButtonVisibility)GetValue(NextButtonVisibilityProperty); } + set { SetValue(NextButtonVisibilityProperty, value); } + } + public static readonly DependencyProperty NextPageProperty = DependencyProperty.Register("NextPage", typeof(WizardPage), typeof(WizardPage), new UIPropertyMetadata(null)); public WizardPage NextPage { @@ -34,14 +62,14 @@ namespace Microsoft.Windows.Controls { get { return (WizardPage)GetValue(PreviousPageProperty); } set { SetValue(PreviousPageProperty, value); } - } + } public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(WizardPage)); public string Title { get { return (string)base.GetValue(TitleProperty); } set { base.SetValue(TitleProperty, value); } - } + } #endregion //Properties diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPageButtonVisibility.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPageButtonVisibility.cs new file mode 100644 index 00000000..98423dfb --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPageButtonVisibility.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + public enum WizardPageButtonVisibility + { + Inherit, + Collapsed, + Hidden, + Visible + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml index d98a5b15..50a65f2e 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml @@ -1,8 +1,18 @@  + xmlns:local="clr-namespace:Microsoft.Windows.Controls" + xmlns:coreConverters="clr-namespace:Microsoft.Windows.Controls.Core.Converters"> + +