116 changed files with 2383 additions and 640 deletions
@ -0,0 +1,38 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2014 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license |
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit |
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids |
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.ComponentModel; |
||||
|
using System.Windows.Controls; |
||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Documents; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.LiveExplorer.Samples.ToggleSwitch.Views |
||||
|
{ |
||||
|
/// <summary> |
||||
|
/// Interaction logic for ToggleSwitchView.xaml |
||||
|
/// </summary> |
||||
|
public partial class ToggleSwitchView : DemoView |
||||
|
{ |
||||
|
public ToggleSwitchView() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,392 @@ |
|||||
|
<!--************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2014 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license |
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit |
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids |
||||
|
|
||||
|
***********************************************************************************--> |
||||
|
<local:DemoView x:Class="Xceed.Wpf.Toolkit.LiveExplorer.Samples.ToggleSwitch.Views.ToggleSwitchView" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
||||
|
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer" |
||||
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" |
||||
|
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters;assembly=Xceed.Wpf.Toolkit" |
||||
|
Title="ToggleSwitch"> |
||||
|
|
||||
|
<local:DemoView.Description> |
||||
|
<!-- //#TODODOC--> |
||||
|
<Paragraph FontSize="14" |
||||
|
FontFamily="Segoe"> |
||||
|
<Run>The ToggleSwitch control is a fully customizable on/off switch that can be used to enhance the UI experience.</Run> |
||||
|
<!--##INCLUDE_OPEN_SOURCE |
||||
|
<LineBreak /> |
||||
|
<LineBreak /> |
||||
|
<Run>This feature is only available in the "Plus" version.</Run> |
||||
|
<LineBreak /> |
||||
|
<Hyperlink NavigateUri="http://www.xceed.com/Extended_WPF_Toolkit_Intro.html" RequestNavigate="Hyperlink_RequestNavigate"> |
||||
|
Click here for more details about Xceed Extended WPF Toolkit Plus. |
||||
|
</Hyperlink> |
||||
|
##END--> |
||||
|
</Paragraph> |
||||
|
</local:DemoView.Description> |
||||
|
|
||||
|
<!--##EXCLUDE_OPEN_SOURCE--> |
||||
|
<local:DemoView.Resources> |
||||
|
<conv:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter" /> |
||||
|
<conv:ThicknessToDoubleConverter x:Key="ThicknessToDoubleConverter" /> |
||||
|
<conv:CornerRadiusToDoubleConverter x:Key="CornerRadiusToDoubleConverter" /> |
||||
|
|
||||
|
<LinearGradientBrush x:Key="customAccentBrush1" |
||||
|
EndPoint="0.5,1" |
||||
|
StartPoint="0.5,0"> |
||||
|
<GradientStop Color="#FF0086c6" |
||||
|
Offset="0" /> |
||||
|
<GradientStop Color="#FF66ccff" |
||||
|
Offset="0.94" /> |
||||
|
<GradientStop Color="#FFddf4ff" |
||||
|
Offset="0.94" /> |
||||
|
<GradientStop Color="#FFddf4ff" |
||||
|
Offset="0.97" /> |
||||
|
<GradientStop Color="#FFddf4ff" |
||||
|
Offset="1" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<LinearGradientBrush x:Key="customAccentBrush2" |
||||
|
EndPoint="0.5,1" |
||||
|
StartPoint="0.5,0"> |
||||
|
<GradientStop Color="#FFff0099" |
||||
|
Offset="0" /> |
||||
|
<GradientStop Color="#FF993366" |
||||
|
Offset="1" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<LinearGradientBrush x:Key="customAccentBrush3" |
||||
|
EndPoint="0.5,1" |
||||
|
StartPoint="0.5,0"> |
||||
|
<GradientStop Color="#FF9DE214" |
||||
|
Offset="0" /> |
||||
|
<GradientStop Color="#FF9DE214" |
||||
|
Offset="0.2" /> |
||||
|
<GradientStop Color="#FF95CA2A" |
||||
|
Offset="0.2" /> |
||||
|
<GradientStop Color="#FF339933" |
||||
|
Offset="1" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<Style x:Key="MetroSampleRadioButtonTemplate" TargetType="RadioButton"> |
||||
|
<Setter Property="Template"> |
||||
|
<Setter.Value> |
||||
|
<ControlTemplate TargetType="RadioButton"> |
||||
|
<Grid> |
||||
|
<VisualStateManager.VisualStateGroups> |
||||
|
<VisualStateGroup x:Name="CommonStates"> |
||||
|
<VisualStateGroup.Transitions> |
||||
|
<VisualTransition GeneratedDuration="0:0:0.2" /> |
||||
|
<VisualTransition From="Normal" |
||||
|
GeneratedDuration="0" |
||||
|
To="Pressed"> |
||||
|
<Storyboard> |
||||
|
<DoubleAnimation Duration="0" |
||||
|
To="0.45" |
||||
|
Storyboard.TargetProperty="(UIElement.Opacity)" |
||||
|
Storyboard.TargetName="rectangle" /> |
||||
|
</Storyboard> |
||||
|
</VisualTransition> |
||||
|
</VisualStateGroup.Transitions> |
||||
|
<VisualState x:Name="Normal" /> |
||||
|
<VisualState x:Name="MouseOver"> |
||||
|
<Storyboard> |
||||
|
<DoubleAnimation Duration="0" |
||||
|
To="0.35" |
||||
|
Storyboard.TargetProperty="(UIElement.Opacity)" |
||||
|
Storyboard.TargetName="rectangle" /> |
||||
|
</Storyboard> |
||||
|
</VisualState> |
||||
|
<VisualState x:Name="Pressed"> |
||||
|
<Storyboard> |
||||
|
<DoubleAnimation Duration="0" |
||||
|
To="0.35" |
||||
|
Storyboard.TargetProperty="(UIElement.Opacity)" |
||||
|
Storyboard.TargetName="rectangle" /> |
||||
|
</Storyboard> |
||||
|
</VisualState> |
||||
|
<VisualState x:Name="Disabled"> |
||||
|
<Storyboard> |
||||
|
<DoubleAnimation Duration="0" |
||||
|
To=".2" |
||||
|
Storyboard.TargetProperty="(UIElement.Opacity)" |
||||
|
Storyboard.TargetName="content" /> |
||||
|
</Storyboard> |
||||
|
</VisualState> |
||||
|
</VisualStateGroup> |
||||
|
<VisualStateGroup x:Name="CheckStates"> |
||||
|
<VisualStateGroup.Transitions> |
||||
|
<VisualTransition GeneratedDuration="0:0:0.2" /> |
||||
|
</VisualStateGroup.Transitions> |
||||
|
<VisualState x:Name="Checked"> |
||||
|
<Storyboard> |
||||
|
<DoubleAnimation Duration="0" |
||||
|
To="1" |
||||
|
Storyboard.TargetProperty="(UIElement.Opacity)" |
||||
|
Storyboard.TargetName="CheckIcon" /> |
||||
|
</Storyboard> |
||||
|
</VisualState> |
||||
|
<VisualState x:Name="Unchecked" /> |
||||
|
</VisualStateGroup> |
||||
|
</VisualStateManager.VisualStateGroups> |
||||
|
<Rectangle x:Name="content" |
||||
|
Width="20" |
||||
|
Height="20" |
||||
|
Fill="{TemplateBinding Background}" /> |
||||
|
<Path x:Name="CheckIcon" |
||||
|
Data="M 619,736 C619,736 617,738 617,738 617,738 621,742 621,742 621,742 629,732 629,732 629,732 627,730 627,730 627,730 621,738 621,738 621,738 619,736 619,736 z" |
||||
|
Fill="White" |
||||
|
FlowDirection="LeftToRight" |
||||
|
Opacity="0" |
||||
|
Stretch="Fill" |
||||
|
UseLayoutRounding="False" |
||||
|
VerticalAlignment="Bottom" |
||||
|
HorizontalAlignment="Right" |
||||
|
Width="12" |
||||
|
Height="12" |
||||
|
Margin="0,0,1,1" /> |
||||
|
<Rectangle x:Name="rectangle" |
||||
|
Fill="White" |
||||
|
Opacity="0" /> |
||||
|
</Grid> |
||||
|
</ControlTemplate> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
</local:DemoView.Resources> |
||||
|
|
||||
|
<Grid> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="Auto" /> |
||||
|
<RowDefinition Height="*" /> |
||||
|
</Grid.RowDefinitions> |
||||
|
|
||||
|
<GroupBox Header="Features" |
||||
|
Margin="5"> |
||||
|
|
||||
|
<GroupBox.Resources> |
||||
|
<Style TargetType="TextBlock"> |
||||
|
<Setter Property="Width" Value="125" /> |
||||
|
<Setter Property="Margin" Value="0,5,0,5" /> |
||||
|
</Style> |
||||
|
<Style x:Key="SubHeader" TargetType="TextBlock"> |
||||
|
<Setter Property="Margin" Value="0,10,0,0" /> |
||||
|
<Setter Property="Foreground" Value="Orange" /> |
||||
|
<Setter Property="TextElement.FontWeight" Value="Bold" /> |
||||
|
</Style> |
||||
|
</GroupBox.Resources> |
||||
|
|
||||
|
<Grid> |
||||
|
<Grid Grid.Row="0"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="1*" /> |
||||
|
<ColumnDefinition Width="1*" /> |
||||
|
<ColumnDefinition Width="1*" /> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<!-- General Section --> |
||||
|
<StackPanel Grid.Column="0" Margin="5,0,0,0"> |
||||
|
<StackPanel> |
||||
|
<TextBlock Text="Section: General" Style="{StaticResource SubHeader}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="IsChecked:" /> |
||||
|
<CheckBox Width="80" Margin="0,5,0,0" |
||||
|
IsChecked="{Binding IsChecked, ElementName=_toggleSwitch}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="IsCheckedLeft:" /> |
||||
|
<CheckBox Width="80" Margin="0,5,0,0" |
||||
|
IsChecked="{Binding IsCheckedLeft, ElementName=_toggleSwitch}" /> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Width:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="50.0" Maximum="300.0" Increment="1.0" |
||||
|
Value="{Binding Width, ElementName=_toggleSwitch}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Height:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="20.0" Maximum="100.0" Increment="0.1" FormatString="N1" |
||||
|
Value="{Binding Height, ElementName=_toggleSwitch}" /> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Corner Radius:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="0.0" Maximum="25.0" |
||||
|
Value="{Binding CornerRadius, ElementName=_toggleSwitch, Converter={StaticResource CornerRadiusToDoubleConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Outer Margin:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="0.0" Maximum="5.0" |
||||
|
Value="{Binding OuterMargin, ElementName=_toggleSwitch, Converter={StaticResource ThicknessToDoubleConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Inner Margin:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="0.0" Maximum="5.0" |
||||
|
Value="{Binding InnerMargin, ElementName=_toggleSwitch, Converter={StaticResource ThicknessToDoubleConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Border Thickness:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="0.0" Maximum="3.0" |
||||
|
Value="{Binding BorderThickness, ElementName=_toggleSwitch, Converter={StaticResource ThicknessToDoubleConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Border Brush:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding BorderBrush, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
|
||||
|
</StackPanel> |
||||
|
|
||||
|
<!-- Checked/Unchecked Sections --> |
||||
|
<StackPanel Grid.Column="1" Margin="5,0,0,0"> |
||||
|
|
||||
|
<StackPanel> |
||||
|
<TextBlock Text="Section: Checked" Style="{StaticResource SubHeader}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Label:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding CheckedLabel, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}"/> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="ToolTip:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding CheckedToolTip, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}"/> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Foreground:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding CheckedForeground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Background:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding CheckedBackground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<StackPanel> |
||||
|
<TextBlock Text="Section: Unchecked" Style="{StaticResource SubHeader}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Label:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding UncheckedLabel, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}"/> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="ToolTip:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding UncheckedToolTip, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}"/> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Foreground:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding UncheckedForeground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Background:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding UncheckedBackground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<!-- Thumb --> |
||||
|
<StackPanel Grid.Column="2" Margin="5,0,0,0"> |
||||
|
<StackPanel> |
||||
|
<TextBlock Text="Section: Thumb" Style="{StaticResource SubHeader}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Width (%):" /> |
||||
|
<xctk:DoubleUpDown Width="80" Minimum="25" Maximum="50" Margin="0,5,0,0" |
||||
|
Value="{Binding ThumbWidth, ElementName=_toggleSwitch}" |
||||
|
ToolTip="Gets/Sets the Width of the Thumb (as a percentage of the total width of the ToggleSwitch)" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Elasticity:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Minimum="10" Maximum="90" Margin="0,5,0,0" |
||||
|
Value="{Binding ThumbElasticity, ElementName=_toggleSwitch}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Right Content:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding ThumbRightContent, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Left Content:" /> |
||||
|
<TextBox Width="80" Margin="0,5,0,0" |
||||
|
Text="{Binding ThumbLeftContent, ElementName=_toggleSwitch, UpdateSourceTrigger=PropertyChanged}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Border Thickness:" /> |
||||
|
<xctk:DoubleUpDown Width="80" Margin="0,5,0,0" Minimum="0.0" Maximum="3.0" |
||||
|
Value="{Binding ThumbBorderThickness, ElementName=_toggleSwitch, Converter={StaticResource ThicknessToDoubleConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Border Brush:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding ThumbBorderBrush, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Foreground:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding ThumbForeground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Background:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding ThumbBackground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Hover Background:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding ThumbHoverBackground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="Pressed Background:" /> |
||||
|
<xctk:ColorPicker Width="80" Margin="0,5,0,0" |
||||
|
SelectedColor="{Binding ThumbPressedBackground, ElementName=_toggleSwitch, Converter={StaticResource SolidColorBrushToColorConverter}}" /> |
||||
|
</StackPanel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
</Grid> |
||||
|
|
||||
|
</Grid> |
||||
|
</GroupBox> |
||||
|
|
||||
|
<StackPanel x:Name="_samplePanel" |
||||
|
Grid.Row="1" |
||||
|
Margin="10"> |
||||
|
|
||||
|
<TextBlock Text="Usage:" |
||||
|
Margin="10" |
||||
|
Style="{StaticResource Header}" /> |
||||
|
|
||||
|
<xctk:ToggleSwitch x:Name="_toggleSwitch" |
||||
|
Width="80.0" |
||||
|
Height="25.5" |
||||
|
Margin="10" |
||||
|
HorizontalAlignment="Left" /> |
||||
|
|
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
<!--##END--> |
||||
|
|
||||
|
<!--##INCLUDE_OPEN_SOURCE |
||||
|
<Image Source="..\OpenSourceImages\ToggleSwitch.png" Width="200" Height="160"/> |
||||
|
##END--> |
||||
|
</local:DemoView> |
||||
|
After Width: | Height: | Size: 2.7 KiB |
@ -0,0 +1,64 @@ |
|||||
|
<!--************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2014 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license |
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit |
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids |
||||
|
|
||||
|
***********************************************************************************--> |
||||
|
<local:DemoView x:Class="Xceed.Wpf.Toolkit.LiveExplorer.Samples.ToggleSwitch.Views.ToggleSwitchView" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
||||
|
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer" |
||||
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" |
||||
|
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters;assembly=Xceed.Wpf.Toolkit" |
||||
|
Title="ToggleSwitch"> |
||||
|
|
||||
|
<local:DemoView.Description> |
||||
|
<!-- //#TODODOC--> |
||||
|
<Paragraph FontSize="14" |
||||
|
FontFamily="Segoe"> |
||||
|
<Run>The ToggleSwitch control is a fully customizable on/off switch that can be used to enhance the UI experience.</Run> |
||||
|
<LineBreak /> |
||||
|
<LineBreak /> |
||||
|
<Run>This feature is only available in the "Plus" version.</Run> |
||||
|
<LineBreak /> |
||||
|
<Hyperlink NavigateUri="http://www.xceed.com/Extended_WPF_Toolkit_Intro.html" RequestNavigate="Hyperlink_RequestNavigate"> |
||||
|
Click here for more details about Xceed Extended WPF Toolkit Plus. |
||||
|
</Hyperlink> |
||||
|
</Paragraph> |
||||
|
</local:DemoView.Description> |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
<Image Source="..\OpenSourceImages\ToggleSwitch.png" Width="200" Height="160"/> |
||||
|
</local:DemoView> |
||||
@ -0,0 +1,38 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2014 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.ComponentModel; |
||||
|
using System.Windows.Controls; |
||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Documents; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.LiveExplorer.Samples.ToggleSwitch.Views |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for ToggleSwitchView.xaml
|
||||
|
/// </summary>
|
||||
|
public partial class ToggleSwitchView : DemoView |
||||
|
{ |
||||
|
public ToggleSwitchView() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,129 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit |
||||
|
{ |
||||
|
public class CollectionControlButton : Button |
||||
|
{ |
||||
|
#region Constructors
|
||||
|
|
||||
|
static CollectionControlButton() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata( typeof( CollectionControlButton ), new FrameworkPropertyMetadata( typeof( CollectionControlButton ) ) ); |
||||
|
} |
||||
|
|
||||
|
public CollectionControlButton() |
||||
|
{ |
||||
|
this.Click += this.CollectionControlButton_Click; |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region IsReadOnly Property
|
||||
|
|
||||
|
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register( "IsReadOnly", typeof( bool ), typeof( CollectionControlButton ), new UIPropertyMetadata( false ) ); |
||||
|
public bool IsReadOnly |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( bool )GetValue( IsReadOnlyProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( IsReadOnlyProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //IsReadOnly
|
||||
|
|
||||
|
#region ItemsSource Property
|
||||
|
|
||||
|
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( "ItemsSource", typeof( IList ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public IList ItemsSource |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( IList )GetValue( ItemsSourceProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( ItemsSourceProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //ItemsSource
|
||||
|
|
||||
|
#region ItemsSourceType Property
|
||||
|
|
||||
|
public static readonly DependencyProperty ItemsSourceTypeProperty = DependencyProperty.Register( "ItemsSourceType", typeof( Type ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public Type ItemsSourceType |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( Type )GetValue( ItemsSourceTypeProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( ItemsSourceTypeProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //ItemsSourceType
|
||||
|
|
||||
|
#region NewItemTypes Property
|
||||
|
|
||||
|
public static readonly DependencyProperty NewItemTypesProperty = DependencyProperty.Register( "NewItemTypes", typeof( IList ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public IList<Type> NewItemTypes |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( IList<Type> )GetValue( NewItemTypesProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( NewItemTypesProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //NewItemTypes
|
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
private void CollectionControlButton_Click( object sender, RoutedEventArgs e ) |
||||
|
{ |
||||
|
CollectionControlDialog collectionControlDialog = new CollectionControlDialog(); |
||||
|
collectionControlDialog.ItemsSource = this.ItemsSource; |
||||
|
collectionControlDialog.NewItemTypes = this.NewItemTypes; |
||||
|
collectionControlDialog.ItemsSourceType = this.ItemsSourceType; |
||||
|
collectionControlDialog.IsReadOnly = this.IsReadOnly; |
||||
|
collectionControlDialog.ShowDialog(); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.Core.Converters |
||||
|
{ |
||||
|
public class CornerRadiusToDoubleConverter : IValueConverter |
||||
|
{ |
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double radius = 0.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
radius = ((CornerRadius)value).TopLeft; |
||||
|
|
||||
|
return radius; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double radius = 0.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
radius = (double)value; |
||||
|
|
||||
|
return new CornerRadius(radius); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.Core.Converters |
||||
|
{ |
||||
|
public class ThicknessToDoubleConverter : IValueConverter |
||||
|
{ |
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double thickness = 1.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
thickness = ((Thickness)value).Top; |
||||
|
|
||||
|
return thickness; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double thickness = 1.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
thickness = (double)value; |
||||
|
|
||||
|
return new Thickness(thickness); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
||||
|
{ |
||||
|
public class CollectionEditor : TypeEditor<CollectionControlButton> |
||||
|
{ |
||||
|
protected override void SetValueDependencyProperty() |
||||
|
{ |
||||
|
ValueProperty = CollectionControlButton.ItemsSourceProperty; |
||||
|
} |
||||
|
|
||||
|
protected override void ResolveValueBinding( PropertyItem propertyItem ) |
||||
|
{ |
||||
|
var type = propertyItem.PropertyType; |
||||
|
|
||||
|
Editor.ItemsSourceType = type; |
||||
|
|
||||
|
if( type.BaseType == typeof( System.Array ) ) |
||||
|
{ |
||||
|
Editor.NewItemTypes = new List<Type>() { type.GetElementType() }; |
||||
|
} |
||||
|
else if( type.GetGenericArguments().Count() > 0 ) |
||||
|
{ |
||||
|
Editor.NewItemTypes = new List<Type>() { type.GetGenericArguments()[ 0 ] }; |
||||
|
} |
||||
|
|
||||
|
base.ResolveValueBinding( propertyItem ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class PropertyGridEditorCollectionControl : CollectionControlButton |
||||
|
{ |
||||
|
static PropertyGridEditorCollectionControl() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata( typeof( PropertyGridEditorCollectionControl ), new FrameworkPropertyMetadata( typeof( PropertyGridEditorCollectionControl ) ) ); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,79 +0,0 @@ |
|||||
<!--*********************************************************************************** |
|
||||
|
|
||||
Extended WPF Toolkit |
|
||||
|
|
||||
Copyright (C) 2007-2013 Xceed Software Inc. |
|
||||
|
|
||||
This program is provided to you under the terms of the Microsoft Public |
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license |
|
||||
|
|
||||
For more features, controls, and fast professional support, |
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit |
|
||||
|
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids |
|
||||
|
|
||||
**********************************************************************************--> |
|
||||
|
|
||||
<UserControl x:Class="Xceed.Wpf.Toolkit.PropertyGrid.Editors.CollectionEditor" |
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|
||||
xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes"> |
|
||||
|
|
||||
<UserControl.Resources> |
|
||||
<Style x:Key="ButtonStyle" TargetType="Button"> |
|
||||
<Setter Property="Background" Value="White" /> |
|
||||
<Setter Property="BorderThickness" Value="0" /> |
|
||||
<Setter Property="Padding" Value="2,0,0,0" /> |
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|
||||
<Setter Property="Template"> |
|
||||
<Setter.Value> |
|
||||
<ControlTemplate TargetType="Button"> |
|
||||
<Grid SnapsToDevicePixels="True"> |
|
||||
|
|
||||
<Grid> |
|
||||
<Grid.ColumnDefinitions> |
|
||||
<ColumnDefinition Width="*" /> |
|
||||
<ColumnDefinition Width="Auto" /> |
|
||||
</Grid.ColumnDefinitions> |
|
||||
|
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True"> |
|
||||
<ContentPresenter Content="{TemplateBinding Content}" |
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" |
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /> |
|
||||
</Border> |
|
||||
|
|
||||
<chrome:ButtonChrome x:Name="ToggleButtonChrome" |
|
||||
Grid.Column="1" |
|
||||
CornerRadius="0,2.75,2.75,0" |
|
||||
RenderEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" |
|
||||
RenderMouseOver="{TemplateBinding IsMouseOver}"> |
|
||||
<Grid x:Name="arrowGlyph" IsHitTestVisible="False" Grid.Column="1" Margin="5"> |
|
||||
<Path x:Name="Arrow" Width="7" Height="4" Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" Fill="#FF000000" /> |
|
||||
</Grid> |
|
||||
</chrome:ButtonChrome> |
|
||||
</Grid> |
|
||||
|
|
||||
</Grid> |
|
||||
<ControlTemplate.Triggers> |
|
||||
<Trigger Property="IsEnabled" Value="False"> |
|
||||
<Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF" /> |
|
||||
<Setter Property="Foreground" Value="Gray" /> |
|
||||
</Trigger> |
|
||||
</ControlTemplate.Triggers> |
|
||||
</ControlTemplate> |
|
||||
</Setter.Value> |
|
||||
</Setter> |
|
||||
</Style> |
|
||||
</UserControl.Resources> |
|
||||
|
|
||||
<Button Grid.Column="1" |
|
||||
IsTabStop="True" |
|
||||
MinHeight="22" |
|
||||
SnapsToDevicePixels="True" |
|
||||
Content="(Collection)" |
|
||||
Style="{StaticResource ButtonStyle}" |
|
||||
Click="Button_Click" /> |
|
||||
</UserControl> |
|
||||
@ -1,51 +0,0 @@ |
|||||
/************************************************************************************* |
|
||||
|
|
||||
Extended WPF Toolkit |
|
||||
|
|
||||
Copyright (C) 2007-2013 Xceed Software Inc. |
|
||||
|
|
||||
This program is provided to you under the terms of the Microsoft Public |
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
|
||||
|
|
||||
For more features, controls, and fast professional support, |
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
|
||||
|
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
|
||||
|
|
||||
***********************************************************************************/ |
|
||||
|
|
||||
using System.Windows; |
|
||||
using System.Windows.Controls; |
|
||||
using System.Windows.Data; |
|
||||
|
|
||||
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Interaction logic for CollectionEditor.xaml
|
|
||||
/// </summary>
|
|
||||
public partial class CollectionEditor : UserControl, ITypeEditor |
|
||||
{ |
|
||||
PropertyItem _item; |
|
||||
|
|
||||
public CollectionEditor() |
|
||||
{ |
|
||||
InitializeComponent(); |
|
||||
} |
|
||||
|
|
||||
private void Button_Click( object sender, RoutedEventArgs e ) |
|
||||
{ |
|
||||
CollectionControlDialog editor = new CollectionControlDialog( _item.PropertyType, _item.DescriptorDefinition.NewItemTypes ); |
|
||||
Binding binding = new Binding( "Value" ); |
|
||||
binding.Source = _item; |
|
||||
binding.Mode = _item.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay; |
|
||||
BindingOperations.SetBinding( editor, CollectionControlDialog.ItemsSourceProperty, binding ); |
|
||||
editor.ShowDialog(); |
|
||||
} |
|
||||
|
|
||||
public FrameworkElement ResolveEditor( PropertyItem propertyItem ) |
|
||||
{ |
|
||||
_item = propertyItem; |
|
||||
return this; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,129 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit |
||||
|
{ |
||||
|
public class CollectionControlButton : Button |
||||
|
{ |
||||
|
#region Constructors
|
||||
|
|
||||
|
static CollectionControlButton() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata( typeof( CollectionControlButton ), new FrameworkPropertyMetadata( typeof( CollectionControlButton ) ) ); |
||||
|
} |
||||
|
|
||||
|
public CollectionControlButton() |
||||
|
{ |
||||
|
this.Click += this.CollectionControlButton_Click; |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region IsReadOnly Property
|
||||
|
|
||||
|
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register( "IsReadOnly", typeof( bool ), typeof( CollectionControlButton ), new UIPropertyMetadata( false ) ); |
||||
|
public bool IsReadOnly |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( bool )GetValue( IsReadOnlyProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( IsReadOnlyProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //IsReadOnly
|
||||
|
|
||||
|
#region ItemsSource Property
|
||||
|
|
||||
|
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( "ItemsSource", typeof( IList ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public IList ItemsSource |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( IList )GetValue( ItemsSourceProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( ItemsSourceProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //ItemsSource
|
||||
|
|
||||
|
#region ItemsSourceType Property
|
||||
|
|
||||
|
public static readonly DependencyProperty ItemsSourceTypeProperty = DependencyProperty.Register( "ItemsSourceType", typeof( Type ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public Type ItemsSourceType |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( Type )GetValue( ItemsSourceTypeProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( ItemsSourceTypeProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //ItemsSourceType
|
||||
|
|
||||
|
#region NewItemTypes Property
|
||||
|
|
||||
|
public static readonly DependencyProperty NewItemTypesProperty = DependencyProperty.Register( "NewItemTypes", typeof( IList ), typeof( CollectionControlButton ), new UIPropertyMetadata( null ) ); |
||||
|
public IList<Type> NewItemTypes |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return ( IList<Type> )GetValue( NewItemTypesProperty ); |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
SetValue( NewItemTypesProperty, value ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //NewItemTypes
|
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
private void CollectionControlButton_Click( object sender, RoutedEventArgs e ) |
||||
|
{ |
||||
|
CollectionControlDialog collectionControlDialog = new CollectionControlDialog(); |
||||
|
collectionControlDialog.ItemsSource = this.ItemsSource; |
||||
|
collectionControlDialog.NewItemTypes = this.NewItemTypes; |
||||
|
collectionControlDialog.ItemsSourceType = this.ItemsSourceType; |
||||
|
collectionControlDialog.IsReadOnly = this.IsReadOnly; |
||||
|
collectionControlDialog.ShowDialog(); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.Core.Converters |
||||
|
{ |
||||
|
public class CornerRadiusToDoubleConverter : IValueConverter |
||||
|
{ |
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double radius = 0.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
radius = ((CornerRadius)value).TopLeft; |
||||
|
|
||||
|
return radius; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double radius = 0.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
radius = (double)value; |
||||
|
|
||||
|
return new CornerRadius(radius); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.Core.Converters |
||||
|
{ |
||||
|
public class ThicknessToDoubleConverter : IValueConverter |
||||
|
{ |
||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double thickness = 1.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
thickness = ((Thickness)value).Top; |
||||
|
|
||||
|
return thickness; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
|
{ |
||||
|
double thickness = 1.0; |
||||
|
|
||||
|
if (value != null) |
||||
|
thickness = (double)value; |
||||
|
|
||||
|
return new Thickness(thickness); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
/************************************************************************************* |
||||
|
|
||||
|
Extended WPF Toolkit |
||||
|
|
||||
|
Copyright (C) 2007-2013 Xceed Software Inc. |
||||
|
|
||||
|
This program is provided to you under the terms of the Microsoft Public |
||||
|
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
|
||||
|
For more features, controls, and fast professional support, |
||||
|
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
|
||||
|
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
|
||||
|
***********************************************************************************/ |
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
||||
|
{ |
||||
|
public class CollectionEditor : TypeEditor<CollectionControlButton> |
||||
|
{ |
||||
|
protected override void SetValueDependencyProperty() |
||||
|
{ |
||||
|
ValueProperty = CollectionControlButton.ItemsSourceProperty; |
||||
|
} |
||||
|
|
||||
|
protected override void ResolveValueBinding( PropertyItem propertyItem ) |
||||
|
{ |
||||
|
var type = propertyItem.PropertyType; |
||||
|
|
||||
|
Editor.ItemsSourceType = type; |
||||
|
|
||||
|
if( type.BaseType == typeof( System.Array ) ) |
||||
|
{ |
||||
|
Editor.NewItemTypes = new List<Type>() { type.GetElementType() }; |
||||
|
} |
||||
|
else if( type.GetGenericArguments().Count() > 0 ) |
||||
|
{ |
||||
|
Editor.NewItemTypes = new List<Type>() { type.GetGenericArguments()[ 0 ] }; |
||||
|
} |
||||
|
|
||||
|
base.ResolveValueBinding( propertyItem ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class PropertyGridEditorCollectionControl : CollectionControlButton |
||||
|
{ |
||||
|
static PropertyGridEditorCollectionControl() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata( typeof( PropertyGridEditorCollectionControl ), new FrameworkPropertyMetadata( typeof( PropertyGridEditorCollectionControl ) ) ); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,79 +0,0 @@ |
|||||
<!--*********************************************************************************** |
|
||||
|
|
||||
Extended WPF Toolkit |
|
||||
|
|
||||
Copyright (C) 2007-2013 Xceed Software Inc. |
|
||||
|
|
||||
This program is provided to you under the terms of the Microsoft Public |
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license |
|
||||
|
|
||||
For more features, controls, and fast professional support, |
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit |
|
||||
|
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids |
|
||||
|
|
||||
**********************************************************************************--> |
|
||||
|
|
||||
<UserControl x:Class="Xceed.Wpf.Toolkit.PropertyGrid.Editors.CollectionEditor" |
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|
||||
xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes"> |
|
||||
|
|
||||
<UserControl.Resources> |
|
||||
<Style x:Key="ButtonStyle" TargetType="Button"> |
|
||||
<Setter Property="Background" Value="White" /> |
|
||||
<Setter Property="BorderThickness" Value="0" /> |
|
||||
<Setter Property="Padding" Value="2,0,0,0" /> |
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|
||||
<Setter Property="Template"> |
|
||||
<Setter.Value> |
|
||||
<ControlTemplate TargetType="Button"> |
|
||||
<Grid SnapsToDevicePixels="True"> |
|
||||
|
|
||||
<Grid> |
|
||||
<Grid.ColumnDefinitions> |
|
||||
<ColumnDefinition Width="*" /> |
|
||||
<ColumnDefinition Width="Auto" /> |
|
||||
</Grid.ColumnDefinitions> |
|
||||
|
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True"> |
|
||||
<ContentPresenter Content="{TemplateBinding Content}" |
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" |
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /> |
|
||||
</Border> |
|
||||
|
|
||||
<chrome:ButtonChrome x:Name="ToggleButtonChrome" |
|
||||
Grid.Column="1" |
|
||||
CornerRadius="0,2.75,2.75,0" |
|
||||
RenderEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" |
|
||||
RenderMouseOver="{TemplateBinding IsMouseOver}"> |
|
||||
<Grid x:Name="arrowGlyph" IsHitTestVisible="False" Grid.Column="1" Margin="5"> |
|
||||
<Path x:Name="Arrow" Width="7" Height="4" Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" Fill="#FF000000" /> |
|
||||
</Grid> |
|
||||
</chrome:ButtonChrome> |
|
||||
</Grid> |
|
||||
|
|
||||
</Grid> |
|
||||
<ControlTemplate.Triggers> |
|
||||
<Trigger Property="IsEnabled" Value="False"> |
|
||||
<Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF" /> |
|
||||
<Setter Property="Foreground" Value="Gray" /> |
|
||||
</Trigger> |
|
||||
</ControlTemplate.Triggers> |
|
||||
</ControlTemplate> |
|
||||
</Setter.Value> |
|
||||
</Setter> |
|
||||
</Style> |
|
||||
</UserControl.Resources> |
|
||||
|
|
||||
<Button Grid.Column="1" |
|
||||
IsTabStop="True" |
|
||||
MinHeight="22" |
|
||||
SnapsToDevicePixels="True" |
|
||||
Content="(Collection)" |
|
||||
Style="{StaticResource ButtonStyle}" |
|
||||
Click="Button_Click" /> |
|
||||
</UserControl> |
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue