Browse Source

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.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
54fdc2c072
  1. 23
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml
  2. 98
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml.cs
  3. 7
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml
  4. 2
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.DateTime/Views/HomeView.xaml.cs
  5. 14
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml
  6. 79
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.PropertyGrid/Views/HomeView.xaml.cs
  7. 22
      ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Wizard/Views/HomeView.xaml
  8. 8
      ExtendedWPFToolkitSolution/Src/Samples/Samples/App.xaml.cs
  9. 40
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/WizardPageButtonVisibilityConverter.cs
  10. 2
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj
  11. 246
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs
  12. 40
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPage.cs
  13. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/WizardPageButtonVisibility.cs
  14. 75
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml

23
ExtendedWPFToolkitSolution/Src/Samples/Modules/Samples.Modules.Button/Views/HomeView.xaml

@ -1,6 +1,7 @@
<UserControl x:Class="Samples.Modules.Button.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
@ -8,11 +9,27 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="Button Module Title" />
<!--<extToolkit:DropDownButton Content="Click Me" Margin="15" Command="{Binding MyCommand}" CommandParameter="{Binding ClickCount}" >
<extToolkit:DropDownButton.DropDownContent>
<extToolkit:ColorCanvas />
</extToolkit:DropDownButton.DropDownContent>
</extToolkit:DropDownButton>
<extToolkit:SplitButton Content="Click Me" Margin="15" Grid.Row="1" Command="{Binding MyCommand}" CommandParameter="{Binding ClickCount}" >
<extToolkit:SplitButton.DropDownContent>
<extToolkit:ColorCanvas />
</extToolkit:SplitButton.DropDownContent>
</extToolkit:SplitButton>-->
<!--<TextBlock Text="Button Module Title" />
<TextBlock Grid.Row="1" Margin="10"
Text="Button module text"
TextWrapping="Wrap" />
TextWrapping="Wrap" />-->
</Grid>
</UserControl>

98
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<Item> _items;
public ObservableCollection<Item> Items
{
get { return _items; }
set
{
_items = value;
OnPropertyChanged("Items");
}
}
public MyViewModel()
{
MyCommand = new CustomCommand(Execute, CanExecute);
Items = new ObservableCollection<Item>();
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<object> _execute;
Func<object, bool> _canExecute;
public CustomCommand(Action<object> execute, Func<object, bool> 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);
}
}
}

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

@ -1,11 +1,8 @@
<UserControl x:Class="Samples.Modules.DateTime.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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">
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended">
<Grid>
<TextBlock Text="DateTime View" />
<extToolkit:DateTimePicker Format="Custom" FormatString="HH:mm:ss" />
</Grid>
</UserControl>

2
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
{

14
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">
<Grid>
<TextBlock Text="PropertyGrid View" />
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!--<Button x:Name="_button" Content="Property Grid" Margin="20" HorizontalAlignment="Center" VerticalAlignment="Center" />-->
<ListBox x:Name="_listBox" Margin="20" MinWidth="150">
</ListBox>
<!--<extToolkit:PropertyGrid Grid.Column="1" Name="propertyGrid1" SelectedObject="{Binding ElementName=_button}" />-->
<extToolkit:PropertyGrid Grid.Column="1" Name="propertyGrid1" SelectedObject="{Binding ElementName=_listBox, Path=SelectedItem}" />
</Grid>
</UserControl>

79
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<Person> _pages = new List<Person>();
public List<Person> 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()
{
}
}
}

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

@ -1,11 +1,23 @@
<UserControl 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: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">
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended">
<Grid>
<TextBlock Text="Wizard View" />
<extToolkit:Wizard >
<extToolkit:WizardPage x:Name="page1" Title="Page 1 Title"
Description="Page 1 Description">
<Label Content="Page 1 content" />
</extToolkit:WizardPage>
<extToolkit:WizardPage x:Name="page2" Title="Page 2 Title"
Description="Page 2 Description"
NextPage="{Binding ElementName=page3}"
PreviousPage="{Binding ElementName=page1}" >
<Label Content="Page 2 content" />
</extToolkit:WizardPage>
<extToolkit:WizardPage x:Name="page3" Title="Page 3 Title"
Description="Page 3 Description">
<Label Content="Page 3 content" />
</extToolkit:WizardPage>
</extToolkit:Wizard>
</Grid>
</UserControl>

8
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();

40
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();
}
}
}

2
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj

@ -180,6 +180,7 @@
<Compile Include="ColorCanvas\Implementation\ColorCanvas.cs" />
<Compile Include="Core\Converters\CalculatorMemoryToVisibilityConverter.cs" />
<Compile Include="Core\Converters\TimeFormatToDateTimeFormatConverter.cs" />
<Compile Include="Core\Converters\WizardPageButtonVisibilityConverter.cs" />
<Compile Include="Core\Primitives\HsvColor.cs" />
<Compile Include="ColorPicker\Implementation\ColorItem.cs" />
<Compile Include="ColorPicker\Implementation\ColorPicker.cs" />
@ -274,6 +275,7 @@
<Compile Include="Wizard\Implementation\WizardCommands.cs" />
<Compile Include="Wizard\Implementation\WizardPage.cs" />
<Compile Include="Wizard\Implementation\Wizard.cs" />
<Compile Include="Wizard\Implementation\WizardPageButtonVisibility.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

246
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
}
}
}

40
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

12
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
}
}

75
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Themes/Generic.xaml

@ -1,8 +1,18 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Microsoft.Windows.Controls">
xmlns:local="clr-namespace:Microsoft.Windows.Controls"
xmlns:coreConverters="clr-namespace:Microsoft.Windows.Controls.Core.Converters">
<coreConverters:WizardPageButtonVisibilityConverter x:Key="WizardPageButtonVisibilityConverter" />
<Style TargetType="{x:Type local:Wizard}">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Grid />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Wizard}">
@ -12,21 +22,66 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsPresenter />
<ContentPresenter Content="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}}" />
<StackPanel Background="{TemplateBinding Background}" Grid.Row="1" Margin="7">
<Grid Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Name="PART_HelpButton" Grid.Column="0" MinWidth="75" Content="Help" />
<Button Name="PART_HelpButton" Grid.Column="0" MinWidth="75"
Command="local:WizardCommands.Help"
Content="{TemplateBinding HelpButtonContent}">
<Button.Visibility>
<MultiBinding Converter="{StaticResource WizardPageButtonVisibilityConverter}" >
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="HelpButtonVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CurrentPage.HelpButtonVisibility" />
</MultiBinding>
</Button.Visibility>
</Button>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="PART_CancelButton" Margin="0,0,7,0" MinWidth="75" Content="Cancel" />
<Button Name="PART_BackButton" MinWidth="75" Content="Back" />
<Button Name="PART_NextButton" MinWidth="75" Content="Next" />
<Button Name="PART_FinishButton" Margin="7,0,0,0" MinWidth="75" Content="Finish" />
<Button Name="PART_CancelButton" Margin="0,0,7,0" MinWidth="75"
Command="local:WizardCommands.Cancel"
Content="{TemplateBinding CancelButtonContent}" >
<Button.Visibility>
<MultiBinding Converter="{StaticResource WizardPageButtonVisibilityConverter}" >
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CancelButtonVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CurrentPage.CancelButtonVisibility" />
</MultiBinding>
</Button.Visibility>
</Button>
<Button Name="PART_BackButton" MinWidth="75"
Command="local:WizardCommands.PreviousPage"
Content="{TemplateBinding BackButtonContent}" >
<Button.Visibility>
<MultiBinding Converter="{StaticResource WizardPageButtonVisibilityConverter}" >
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="BackButtonVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CurrentPage.BackButtonVisibility" />
</MultiBinding>
</Button.Visibility>
</Button>
<Button Name="PART_NextButton" MinWidth="75"
Command="local:WizardCommands.NextPage"
Content="{TemplateBinding NextButtonContent}" >
<Button.Visibility>
<MultiBinding Converter="{StaticResource WizardPageButtonVisibilityConverter}" >
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="NextButtonVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CurrentPage.NextButtonVisibility" />
</MultiBinding>
</Button.Visibility>
</Button>
<Button Name="PART_FinishButton" Margin="7,0,0,0" MinWidth="75"
Command="local:WizardCommands.Finish"
Content="{TemplateBinding FinishButtonContent}" >
<Button.Visibility>
<MultiBinding Converter="{StaticResource WizardPageButtonVisibilityConverter}" >
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="FinishButtonVisibility" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="CurrentPage.FinishButtonVisibility" />
</MultiBinding>
</Button.Visibility>
</Button>
</StackPanel>
</Grid>
</StackPanel>
@ -48,7 +103,7 @@
</Grid.RowDefinitions>
<Grid Name="PART_Header" >
<StackPanel Grid.Column="0">
<TextBlock Margin="16,9,0,1" TextWrapping="Wrap" FontWeight="Bold" Text="{TemplateBinding Caption}" />
<TextBlock Margin="16,9,0,1" TextWrapping="Wrap" FontWeight="Bold" Text="{TemplateBinding Title}" />
<TextBlock Margin="32,0,0,3" TextWrapping="Wrap" Text="{TemplateBinding Description}" />
</StackPanel>
</Grid>

Loading…
Cancel
Save