Browse Source

finally got SplitButton popup behavior working properly.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
2ed2b328f6
  1. 19
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/SplitButton.cs
  2. 6
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml

19
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/SplitButton.cs

@ -3,7 +3,6 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Diagnostics;
namespace Microsoft.Windows.Controls namespace Microsoft.Windows.Controls
{ {
@ -74,8 +73,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnIsOpenChanged(bool oldValue, bool newValue) protected virtual void OnIsOpenChanged(bool oldValue, bool newValue)
{ {
// TODO: Add your property changed side-effects. Descendants can override as well. // TODO: check for cancel event args on an OnOpening event
Debug.WriteLine("{0} : {1}", oldValue, newValue);
} }
#endregion //IsOpen #endregion //IsOpen
@ -89,25 +87,24 @@ namespace Microsoft.Windows.Controls
base.OnApplyTemplate(); base.OnApplyTemplate();
_toggleButton = (ToggleButton)GetTemplateChild("PART_ToggleButton"); _toggleButton = (ToggleButton)GetTemplateChild("PART_ToggleButton");
_toggleButton.Click += new RoutedEventHandler(_toggleButton_Click); _toggleButton.Click += ToggleButton_Click;
_popup = (Popup)GetTemplateChild("PART_Popup"); _popup = (Popup)GetTemplateChild("PART_Popup");
_popup.Opened += Popup_Opened; _popup.Opened += Popup_Opened;
} }
void _toggleButton_Click(object sender, RoutedEventArgs e)
{
Debug.WriteLine("IsOpen : {0} | IsChecked : {1}", IsOpen, _toggleButton.IsChecked);
}
#endregion //Base Class Overrides #endregion //Base Class Overrides
#region Event Handlers #region Event Handlers
void ToggleButton_Click(object sender, RoutedEventArgs e)
{
}
void Popup_Opened(object sender, EventArgs e) void Popup_Opened(object sender, EventArgs e)
{ {
Mouse.Capture(this, CaptureMode.SubTree);
} }
private void OnKeyDown(object sender, KeyEventArgs e) private void OnKeyDown(object sender, KeyEventArgs e)

6
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml

@ -1220,9 +1220,9 @@
<ContentPresenter Name="Content" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="true" /> <ContentPresenter Name="Content" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="true" />
</Button> </Button>
<ToggleButton x:Name="PART_ToggleButton" Grid.Column="1" IsTabStop="False" <ToggleButton x:Name="PART_ToggleButton" Grid.Column="1" IsTabStop="False"
Style="{StaticResource SplitButtonDropDownStyle}" Style="{StaticResource SplitButtonDropDownStyle}"
ClickMode="Press" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" > IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">
<Grid x:Name="arrowGlyph" IsHitTestVisible="False"> <Grid x:Name="arrowGlyph" IsHitTestVisible="False">
<Path 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"/> <Path 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> </Grid>

Loading…
Cancel
Save