3 changed files with 226 additions and 3 deletions
@ -0,0 +1,99 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Navigation; |
||||
|
using System.Windows.Shapes; |
||||
|
using System.Windows.Controls.Primitives; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public class SplitButton : ContentControl |
||||
|
{ |
||||
|
#region Members
|
||||
|
|
||||
|
ToggleButton _dropDownButton; |
||||
|
Popup _popup; |
||||
|
|
||||
|
#endregion //Members
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static SplitButton() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(SplitButton), new FrameworkPropertyMetadata(typeof(SplitButton))); |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region DropDownContent
|
||||
|
|
||||
|
public static readonly DependencyProperty DropDownContentProperty = DependencyProperty.Register("DropDownContent", typeof(object), typeof(SplitButton), new UIPropertyMetadata(null, OnDropDownContentChanged)); |
||||
|
public object DropDownContent |
||||
|
{ |
||||
|
get { return (object)GetValue(DropDownContentProperty); } |
||||
|
set { SetValue(DropDownContentProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnDropDownContentChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
SplitButton splitButton = o as SplitButton; |
||||
|
if (splitButton != null) |
||||
|
splitButton.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 IsOpen
|
||||
|
|
||||
|
public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(SplitButton), new UIPropertyMetadata(false, OnIsOpenChanged)); |
||||
|
public bool IsOpen |
||||
|
{ |
||||
|
get { return (bool)GetValue(IsOpenProperty); } |
||||
|
set { SetValue(IsOpenProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnIsOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
SplitButton splitButton = o as SplitButton; |
||||
|
if (splitButton != null) |
||||
|
splitButton.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue); |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnIsOpenChanged(bool oldValue, bool newValue) |
||||
|
{ |
||||
|
// TODO: Add your property changed side-effects. Descendants can override as well.
|
||||
|
} |
||||
|
|
||||
|
#endregion //IsOpen
|
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
|
||||
|
_dropDownButton = (ToggleButton)GetTemplateChild("PART_ToggleButton"); |
||||
|
|
||||
|
_popup = (Popup)GetTemplateChild("PART_Popup"); |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue