Skip to content

Commit 6303629

Browse files
authored
Fixes #1091 (#1206)
Toggle button inside of the popup box template should inherit the PopupBox's TabIndex
1 parent 8f7e1ff commit 6303629

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

MaterialDesignThemes.Wpf.Tests/MaterialDesignThemes.Wpf.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<Compile Include="DialogHostTests.cs" />
5050
<Compile Include="MdixHelper.cs" />
5151
<Compile Include="PaletteHelperFixture.cs" />
52+
<Compile Include="PopupBoxTests.cs" />
5253
<Compile Include="Properties\AssemblyInfo.cs" />
5354
<Compile Include="VisualTreeHelper.cs" />
5455
</ItemGroup>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.ComponentModel;
2+
using System.Windows;
3+
using System.Windows.Controls.Primitives;
4+
using Xunit;
5+
6+
namespace MaterialDesignThemes.Wpf.Tests
7+
{
8+
public class PopupBoxTests
9+
{
10+
[StaFact]
11+
[Description("Issue 1091")]
12+
public void ToggleButtonInheritsTabIndex()
13+
{
14+
var popupBox = new PopupBox { TabIndex = 3 };
15+
popupBox.ApplyDefaultStyle();
16+
17+
ToggleButton togglePart = popupBox.FindVisualChild<ToggleButton>(PopupBox.TogglePartName);
18+
19+
Assert.Equal(3, togglePart.TabIndex);
20+
}
21+
}
22+
}

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth3" />
7474
<Setter Property="TextElement.FontWeight" Value="Normal" />
7575
<Setter Property="Padding" Value="0 8 0 8" />
76-
<Setter Property="Focusable" Value="False" />
76+
<Setter Property="Focusable" Value="True" />
7777
<Setter Property="Template">
7878
<Setter.Value>
7979
<ControlTemplate TargetType="{x:Type wpf:PopupBox}">
@@ -98,8 +98,7 @@
9898
<Grid>
9999
<ToggleButton x:Name="PART_Toggle" Style="{StaticResource ToggleButtonStyle}" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsPopupOpen, Mode=TwoWay}"
100100
Content="{TemplateBinding ToggleContent}" ContentTemplate="{TemplateBinding ToggleContentTemplate}"
101-
Cursor="Hand"
102-
VerticalAlignment="Center"
101+
Cursor="Hand" TabIndex="{TemplateBinding TabIndex}" VerticalAlignment="Center"
103102
/>
104103
<controlzEx:PopupEx x:Name="PART_Popup"
105104
IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsPopupOpen, Mode=TwoWay}"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Controlz/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Templated/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)