Init
This commit is contained in:
@@ -0,0 +1,487 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using Xceed.Wpf.Toolkit.Primitives;
|
||||
using System.Windows.Media;
|
||||
using Xceed.Wpf.Toolkit.Core.Utilities;
|
||||
|
||||
namespace Xceed.Wpf.Toolkit
|
||||
{
|
||||
[TemplatePart( Name = PART_DropDownButton, Type = typeof( ToggleButton ) )]
|
||||
[TemplatePart( Name = PART_ContentPresenter, Type = typeof( ContentPresenter ) )]
|
||||
[TemplatePart( Name = PART_Popup, Type = typeof( Popup ) )]
|
||||
public class DropDownButton : ContentControl, ICommandSource
|
||||
{
|
||||
private const string PART_DropDownButton = "PART_DropDownButton";
|
||||
private const string PART_ContentPresenter = "PART_ContentPresenter";
|
||||
private const string PART_Popup = "PART_Popup";
|
||||
|
||||
#region Members
|
||||
|
||||
private ContentPresenter _contentPresenter;
|
||||
private Popup _popup;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static DropDownButton()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata( typeof( DropDownButton ), new FrameworkPropertyMetadata( typeof( DropDownButton ) ) );
|
||||
}
|
||||
|
||||
public DropDownButton()
|
||||
{
|
||||
Keyboard.AddKeyDownHandler( this, OnKeyDown );
|
||||
Mouse.AddPreviewMouseDownOutsideCapturedElementHandler( this, OnMouseDownOutsideCapturedElement );
|
||||
}
|
||||
|
||||
#endregion //Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
private System.Windows.Controls.Primitives.ButtonBase _button;
|
||||
protected System.Windows.Controls.Primitives.ButtonBase Button
|
||||
{
|
||||
get
|
||||
{
|
||||
return _button;
|
||||
}
|
||||
set
|
||||
{
|
||||
if( _button != null )
|
||||
_button.Click -= DropDownButton_Click;
|
||||
|
||||
_button = value;
|
||||
|
||||
if( _button != null )
|
||||
_button.Click += DropDownButton_Click;
|
||||
}
|
||||
}
|
||||
|
||||
#region DropDownContent
|
||||
|
||||
public static readonly DependencyProperty DropDownContentProperty = DependencyProperty.Register( "DropDownContent", typeof( object ), typeof( DropDownButton ), new UIPropertyMetadata( null, OnDropDownContentChanged ) );
|
||||
public object DropDownContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return ( object )GetValue( DropDownContentProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( DropDownContentProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnDropDownContentChanged( DependencyObject o, DependencyPropertyChangedEventArgs e )
|
||||
{
|
||||
DropDownButton dropDownButton = o as DropDownButton;
|
||||
if( dropDownButton != null )
|
||||
dropDownButton.OnDropDownContentChanged( ( object )e.OldValue, ( object )e.NewValue );
|
||||
}
|
||||
|
||||
protected virtual void OnDropDownContentChanged( object oldValue, object newValue )
|
||||
{
|
||||
// TODO: Add your property changed side-effects. Descendants can override as well.
|
||||
}
|
||||
|
||||
#endregion //DropDownContent
|
||||
|
||||
#region DropDownPosition
|
||||
|
||||
public static readonly DependencyProperty DropDownPositionProperty = DependencyProperty.Register( "DropDownPosition", typeof( PlacementMode )
|
||||
, typeof( DropDownButton ), new UIPropertyMetadata( PlacementMode.Bottom ) );
|
||||
public PlacementMode DropDownPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return (PlacementMode)GetValue( DropDownPositionProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( DropDownPositionProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsOpen
|
||||
|
||||
public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register( "IsOpen", typeof( bool ), typeof( DropDownButton ), new UIPropertyMetadata( false, OnIsOpenChanged ) );
|
||||
public bool IsOpen
|
||||
{
|
||||
get
|
||||
{
|
||||
return ( bool )GetValue( IsOpenProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( IsOpenProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnIsOpenChanged( DependencyObject o, DependencyPropertyChangedEventArgs e )
|
||||
{
|
||||
DropDownButton dropDownButton = o as DropDownButton;
|
||||
if( dropDownButton != null )
|
||||
dropDownButton.OnIsOpenChanged( ( bool )e.OldValue, ( bool )e.NewValue );
|
||||
}
|
||||
|
||||
protected virtual void OnIsOpenChanged( bool oldValue, bool newValue )
|
||||
{
|
||||
if( newValue )
|
||||
RaiseRoutedEvent( DropDownButton.OpenedEvent );
|
||||
else
|
||||
RaiseRoutedEvent( DropDownButton.ClosedEvent );
|
||||
}
|
||||
|
||||
#endregion //IsOpen
|
||||
|
||||
#region MaxDropDownHeight
|
||||
|
||||
public static readonly DependencyProperty MaxDropDownHeightProperty = DependencyProperty.Register( "MaxDropDownHeight", typeof( double )
|
||||
, typeof( DropDownButton ), new UIPropertyMetadata( SystemParameters.PrimaryScreenHeight / 2.0, OnMaxDropDownHeightChanged ) );
|
||||
public double MaxDropDownHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetValue( MaxDropDownHeightProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( MaxDropDownHeightProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnMaxDropDownHeightChanged( DependencyObject o, DependencyPropertyChangedEventArgs e )
|
||||
{
|
||||
var dropDownButton = o as DropDownButton;
|
||||
if( dropDownButton != null )
|
||||
dropDownButton.OnMaxDropDownHeightChanged( (double)e.OldValue, (double)e.NewValue );
|
||||
}
|
||||
|
||||
protected virtual void OnMaxDropDownHeightChanged( double oldValue, double newValue )
|
||||
{
|
||||
// TODO: Add your property changed side-effects. Descendants can override as well.
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion //Properties
|
||||
|
||||
#region Base Class Overrides
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
this.Button = this.GetTemplateChild( PART_DropDownButton ) as ToggleButton;
|
||||
|
||||
_contentPresenter = GetTemplateChild( PART_ContentPresenter ) as ContentPresenter;
|
||||
|
||||
if( _popup != null )
|
||||
_popup.Opened -= Popup_Opened;
|
||||
|
||||
_popup = GetTemplateChild( PART_Popup ) as Popup;
|
||||
|
||||
if( _popup != null )
|
||||
_popup.Opened += Popup_Opened;
|
||||
}
|
||||
|
||||
protected override void OnIsKeyboardFocusWithinChanged( DependencyPropertyChangedEventArgs e )
|
||||
{
|
||||
base.OnIsKeyboardFocusWithinChanged( e );
|
||||
if( !( bool )e.NewValue )
|
||||
{
|
||||
this.CloseDropDown( false );
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnGotFocus( RoutedEventArgs e )
|
||||
{
|
||||
base.OnGotFocus( e );
|
||||
if( this.Button != null )
|
||||
{
|
||||
this.Button.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //Base Class Overrides
|
||||
|
||||
#region Events
|
||||
|
||||
public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent( "Click", RoutingStrategy.Bubble, typeof( RoutedEventHandler ), typeof( DropDownButton ) );
|
||||
public event RoutedEventHandler Click
|
||||
{
|
||||
add
|
||||
{
|
||||
AddHandler( ClickEvent, value );
|
||||
}
|
||||
remove
|
||||
{
|
||||
RemoveHandler( ClickEvent, value );
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent( "Opened", RoutingStrategy.Bubble, typeof( RoutedEventHandler ), typeof( DropDownButton ) );
|
||||
public event RoutedEventHandler Opened
|
||||
{
|
||||
add
|
||||
{
|
||||
AddHandler( OpenedEvent, value );
|
||||
}
|
||||
remove
|
||||
{
|
||||
RemoveHandler( OpenedEvent, value );
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent( "Closed", RoutingStrategy.Bubble, typeof( RoutedEventHandler ), typeof( DropDownButton ) );
|
||||
public event RoutedEventHandler Closed
|
||||
{
|
||||
add
|
||||
{
|
||||
AddHandler( ClosedEvent, value );
|
||||
}
|
||||
remove
|
||||
{
|
||||
RemoveHandler( ClosedEvent, value );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //Events
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void OnKeyDown( object sender, KeyEventArgs e )
|
||||
{
|
||||
if( !IsOpen )
|
||||
{
|
||||
if( KeyboardUtilities.IsKeyModifyingPopupState( e ) )
|
||||
{
|
||||
IsOpen = true;
|
||||
// ContentPresenter items will get focus in Popup_Opened().
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( KeyboardUtilities.IsKeyModifyingPopupState( e ) )
|
||||
{
|
||||
CloseDropDown( true );
|
||||
e.Handled = true;
|
||||
}
|
||||
else if( e.Key == Key.Escape )
|
||||
{
|
||||
CloseDropDown( true );
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseDownOutsideCapturedElement( object sender, MouseButtonEventArgs e )
|
||||
{
|
||||
CloseDropDown( true );
|
||||
}
|
||||
|
||||
private void DropDownButton_Click( object sender, RoutedEventArgs e )
|
||||
{
|
||||
OnClick();
|
||||
}
|
||||
|
||||
void CanExecuteChanged( object sender, EventArgs e )
|
||||
{
|
||||
CanExecuteChanged();
|
||||
}
|
||||
|
||||
private void Popup_Opened( object sender, EventArgs e )
|
||||
{
|
||||
// Set the focus on the content of the ContentPresenter.
|
||||
if( _contentPresenter != null )
|
||||
{
|
||||
_contentPresenter.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //Event Handlers
|
||||
|
||||
#region Methods
|
||||
|
||||
private void CanExecuteChanged()
|
||||
{
|
||||
if( Command != null )
|
||||
{
|
||||
RoutedCommand command = Command as RoutedCommand;
|
||||
|
||||
// If a RoutedCommand.
|
||||
if( command != null )
|
||||
IsEnabled = command.CanExecute( CommandParameter, CommandTarget ) ? true : false;
|
||||
// If a not RoutedCommand.
|
||||
else
|
||||
IsEnabled = Command.CanExecute( CommandParameter ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the drop down.
|
||||
/// </summary>
|
||||
private void CloseDropDown( bool isFocusOnButton )
|
||||
{
|
||||
if( IsOpen )
|
||||
{
|
||||
IsOpen = false;
|
||||
}
|
||||
ReleaseMouseCapture();
|
||||
|
||||
if( isFocusOnButton && (this.Button != null) )
|
||||
{
|
||||
Button.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnClick()
|
||||
{
|
||||
RaiseRoutedEvent( DropDownButton.ClickEvent );
|
||||
RaiseCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises routed events.
|
||||
/// </summary>
|
||||
private void RaiseRoutedEvent( RoutedEvent routedEvent )
|
||||
{
|
||||
RoutedEventArgs args = new RoutedEventArgs( routedEvent, this );
|
||||
RaiseEvent( args );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the command's Execute event.
|
||||
/// </summary>
|
||||
private void RaiseCommand()
|
||||
{
|
||||
if( Command != null )
|
||||
{
|
||||
RoutedCommand routedCommand = Command as RoutedCommand;
|
||||
|
||||
if( routedCommand == null )
|
||||
( ( ICommand )Command ).Execute( CommandParameter );
|
||||
else
|
||||
routedCommand.Execute( CommandParameter, CommandTarget );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unhooks a command from the Command property.
|
||||
/// </summary>
|
||||
/// <param name="oldCommand">The old command.</param>
|
||||
/// <param name="newCommand">The new command.</param>
|
||||
private void UnhookCommand( ICommand oldCommand, ICommand newCommand )
|
||||
{
|
||||
EventHandler handler = CanExecuteChanged;
|
||||
oldCommand.CanExecuteChanged -= handler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hooks up a command to the CanExecuteChnaged event handler.
|
||||
/// </summary>
|
||||
/// <param name="oldCommand">The old command.</param>
|
||||
/// <param name="newCommand">The new command.</param>
|
||||
private void HookUpCommand( ICommand oldCommand, ICommand newCommand )
|
||||
{
|
||||
EventHandler handler = new EventHandler( CanExecuteChanged );
|
||||
canExecuteChangedHandler = handler;
|
||||
if( newCommand != null )
|
||||
newCommand.CanExecuteChanged += canExecuteChangedHandler;
|
||||
}
|
||||
|
||||
#endregion //Methods
|
||||
|
||||
#region ICommandSource Members
|
||||
|
||||
// Keeps a copy of the CanExecuteChnaged handler so it doesn't get garbage collected.
|
||||
private EventHandler canExecuteChangedHandler;
|
||||
|
||||
#region Command
|
||||
|
||||
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register( "Command", typeof( ICommand ), typeof( DropDownButton ), new PropertyMetadata( ( ICommand )null, OnCommandChanged ) );
|
||||
[TypeConverter( typeof( CommandConverter ) )]
|
||||
public ICommand Command
|
||||
{
|
||||
get
|
||||
{
|
||||
return ( ICommand )GetValue( CommandProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( CommandProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnCommandChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
|
||||
{
|
||||
DropDownButton dropDownButton = d as DropDownButton;
|
||||
if( dropDownButton != null )
|
||||
dropDownButton.OnCommandChanged( ( ICommand )e.OldValue, ( ICommand )e.NewValue );
|
||||
}
|
||||
|
||||
protected virtual void OnCommandChanged( ICommand oldValue, ICommand newValue )
|
||||
{
|
||||
// If old command is not null, then we need to remove the handlers.
|
||||
if( oldValue != null )
|
||||
UnhookCommand( oldValue, newValue );
|
||||
|
||||
HookUpCommand( oldValue, newValue );
|
||||
|
||||
CanExecuteChanged(); //may need to call this when changing the command parameter or target.
|
||||
}
|
||||
|
||||
#endregion //Command
|
||||
|
||||
public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register( "CommandParameter", typeof( object ), typeof( DropDownButton ), new PropertyMetadata( null ) );
|
||||
public object CommandParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetValue( CommandParameterProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( CommandParameterProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register( "CommandTarget", typeof( IInputElement ), typeof( DropDownButton ), new PropertyMetadata( null ) );
|
||||
public IInputElement CommandTarget
|
||||
{
|
||||
get
|
||||
{
|
||||
return ( IInputElement )GetValue( CommandTargetProperty );
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue( CommandTargetProperty, value );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //ICommandSource Members
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<!--***********************************************************************************
|
||||
|
||||
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
|
||||
|
||||
**********************************************************************************-->
|
||||
|
||||
<ResourceDictionary 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"
|
||||
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters"
|
||||
xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes"
|
||||
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../../Themes/Aero2/Common.xaml" />
|
||||
<ResourceDictionary Source="../../Themes/Aero2/Glyphs.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<conv:InverseBoolConverter x:Key="InverseBoolConverter" />
|
||||
|
||||
|
||||
<!-- =============================================================================== -->
|
||||
<!-- DropDownButton -->
|
||||
<!-- =============================================================================== -->
|
||||
|
||||
<Style TargetType="{x:Type local:DropDownButton}">
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="IsTabStop"
|
||||
Value="False" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalBackgroundKey}}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalOuterBorderKey}}" />
|
||||
<Setter Property="Padding"
|
||||
Value="3" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:DropDownButton}">
|
||||
<Grid x:Name="MainGrid"
|
||||
SnapsToDevicePixels="True">
|
||||
<ToggleButton x:Name="PART_DropDownButton"
|
||||
Grid.Column="1"
|
||||
IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<ContentPresenter />
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<Grid>
|
||||
<chrome:ButtonChrome x:Name="ToggleButtonChrome"
|
||||
Background="{TemplateBinding Background}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
RenderChecked="{TemplateBinding IsOpen}"
|
||||
RenderEnabled="{TemplateBinding IsEnabled}"
|
||||
RenderMouseOver="{Binding IsMouseOver, ElementName=PART_DropDownButton}"
|
||||
RenderPressed="{Binding IsPressed, ElementName=PART_DropDownButton}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
RecognizesAccessKey="true" />
|
||||
<Grid x:Name="arrowGlyph"
|
||||
IsHitTestVisible="False"
|
||||
Margin="4,3,4,3"
|
||||
Grid.Column="1">
|
||||
<Path x:Name="Arrow"
|
||||
Width="9"
|
||||
Height="5"
|
||||
Data="{StaticResource DownArrowGeometry}"
|
||||
Fill="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
|
||||
Margin="0,1,0,0"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</chrome:ButtonChrome>
|
||||
</Grid>
|
||||
</ToggleButton>
|
||||
|
||||
<Popup x:Name="PART_Popup"
|
||||
HorizontalOffset="1"
|
||||
VerticalOffset="1"
|
||||
AllowsTransparency="True"
|
||||
StaysOpen="False"
|
||||
Placement="{TemplateBinding DropDownPosition}"
|
||||
Focusable="False"
|
||||
IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}"
|
||||
ToolTip="{x:Static sys:String.Empty}">
|
||||
<Popup.Resources>
|
||||
<Style TargetType="ToolTip">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Content"
|
||||
Value="{x:Static sys:String.Empty}">
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Popup.Resources>
|
||||
<Border BorderThickness="1"
|
||||
Background="{StaticResource PanelBackgroundBrush}"
|
||||
BorderBrush="{StaticResource PopupDarkBorderBrush}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}">
|
||||
<ScrollViewer x:Name="DropDownScrollViewer"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ContentPresenter x:Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding DropDownContent}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled"
|
||||
Value="False">
|
||||
<Setter Property="Fill"
|
||||
TargetName="Arrow"
|
||||
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
|
||||
<Setter TargetName="ToggleButtonChrome"
|
||||
Property="Foreground"
|
||||
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
172
Src/Xceed.Wpf.Toolkit/DropDownButton/Themes/Generic.xaml
Normal file
172
Src/Xceed.Wpf.Toolkit/DropDownButton/Themes/Generic.xaml
Normal file
@@ -0,0 +1,172 @@
|
||||
<!--***********************************************************************************
|
||||
|
||||
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
|
||||
|
||||
**********************************************************************************-->
|
||||
|
||||
<ResourceDictionary 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"
|
||||
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters"
|
||||
xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes"
|
||||
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="..\..\Themes\Generic\Glyphs.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<conv:InverseBoolConverter x:Key="InverseBoolConverter" />
|
||||
|
||||
<LinearGradientBrush x:Key="PopupDarkBorderBrush"
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFA3AEB9"
|
||||
Offset="0" />
|
||||
<GradientStop Color="#FF8399A9"
|
||||
Offset="0.375" />
|
||||
<GradientStop Color="#FF718597"
|
||||
Offset="0.375" />
|
||||
<GradientStop Color="#FF617584"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="PopupBackgroundBrush"
|
||||
StartPoint="0,0"
|
||||
EndPoint="0,1">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Offset="0"
|
||||
Color="#FFffffff" />
|
||||
<GradientStop Offset="1"
|
||||
Color="#FFE8EBED" />
|
||||
</GradientStopCollection>
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<Style TargetType="{x:Type local:DropDownButton}">
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="IsTabStop"
|
||||
Value="False" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalBackgroundKey}}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalOuterBorderKey}}" />
|
||||
<Setter Property="Padding"
|
||||
Value="3" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:DropDownButton}">
|
||||
<Grid x:Name="MainGrid"
|
||||
SnapsToDevicePixels="True">
|
||||
<ToggleButton x:Name="PART_DropDownButton"
|
||||
Grid.Column="1"
|
||||
IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<ContentPresenter />
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<Grid>
|
||||
<chrome:ButtonChrome x:Name="ToggleButtonChrome"
|
||||
Background="{TemplateBinding Background}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="2.75"
|
||||
RenderChecked="{TemplateBinding IsOpen}"
|
||||
RenderEnabled="{TemplateBinding IsEnabled}"
|
||||
RenderMouseOver="{Binding IsMouseOver, ElementName=PART_DropDownButton}"
|
||||
RenderPressed="{Binding IsPressed, ElementName=PART_DropDownButton}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
RecognizesAccessKey="true" />
|
||||
<Grid x:Name="arrowGlyph"
|
||||
IsHitTestVisible="False"
|
||||
Margin="4,3,4,3"
|
||||
Grid.Column="1">
|
||||
<Path x:Name="Arrow"
|
||||
Width="9"
|
||||
Height="5"
|
||||
Data="{StaticResource DownArrowGeometry}"
|
||||
Fill="#FF000000"
|
||||
Margin="0,1,0,0"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</chrome:ButtonChrome>
|
||||
</Grid>
|
||||
</ToggleButton>
|
||||
|
||||
<Popup x:Name="PART_Popup"
|
||||
HorizontalOffset="1"
|
||||
VerticalOffset="1"
|
||||
AllowsTransparency="True"
|
||||
StaysOpen="False"
|
||||
Placement="{TemplateBinding DropDownPosition}"
|
||||
Focusable="False"
|
||||
IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}"
|
||||
ToolTip="{x:Static sys:String.Empty}">
|
||||
<Popup.Resources>
|
||||
<Style TargetType="ToolTip">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Content"
|
||||
Value="{x:Static sys:String.Empty}">
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Popup.Resources>
|
||||
<Border BorderThickness="1"
|
||||
Background="{StaticResource PopupBackgroundBrush}"
|
||||
BorderBrush="{StaticResource PopupDarkBorderBrush}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}">
|
||||
<ScrollViewer x:Name="DropDownScrollViewer"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ContentPresenter x:Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding DropDownContent}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled"
|
||||
Value="False">
|
||||
<Setter Property="Fill"
|
||||
TargetName="Arrow"
|
||||
Value="#AFAFAF" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user