File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
MaterialDesignThemes.UITests/WPF/TabControls
MaterialDesignThemes.Wpf/Themes Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -121,4 +121,38 @@ public async Task TabItem_ShouldKeepDataContext_WhenContextMenuOpens(string hori
121
121
122
122
recorder . Success ( ) ;
123
123
}
124
+
125
+ [ Fact ]
126
+ [ Description ( "Issue 3271" ) ]
127
+ public async Task TabControl_ShouldRespectSelectedContentTemplate_WhenSetDirectlyOnTabItem ( )
128
+ {
129
+ await using var recorder = new TestRecorder ( App ) ;
130
+
131
+ //Arrange
132
+ IVisualElement < TabControl > tabControl = await LoadXaml < TabControl > ( """
133
+ <TabControl materialDesign:ColorZoneAssist.Mode="PrimaryMid"
134
+ Style="{StaticResource MaterialDesignFilledTabControl}">
135
+ <TabControl.Resources>
136
+ <DataTemplate x:Key="CustomContentTemplate">
137
+ <Border Background="Fuchsia" Padding="10" Margin="10" CornerRadius="10">
138
+ <TextBlock Text="{Binding .}" />
139
+ </Border>
140
+ </DataTemplate>
141
+ </TabControl.Resources>
142
+ <TabItem Content="Tab content string" ContentTemplate="{StaticResource CustomContentTemplate}" />
143
+ </TabControl>
144
+ """ ) ;
145
+
146
+ IVisualElement < Border > selectedContentBorder = await tabControl . GetElement < Border > ( "PART_BorderSelectedContent" ) ;
147
+
148
+ //Act
149
+ var customContentBorder = await selectedContentBorder . GetElement < Border > ( "/Border" ) ;
150
+ IVisualElement < TextBlock > customContent = await customContentBorder . GetElement < TextBlock > ( @"/TextBlock" ) ;
151
+
152
+ //Assert
153
+ Assert . Equal ( Colors . Fuchsia , await customContentBorder . GetBackgroundColor ( ) ) ;
154
+ Assert . Equal ( "Tab content string" , await customContent . GetText ( ) ) ;
155
+
156
+ recorder . Success ( ) ;
157
+ }
124
158
}
Original file line number Diff line number Diff line change 72
72
<ContentPresenter x : Name =" PART_SelectedContentHost"
73
73
Margin =" {TemplateBinding Padding}"
74
74
ContentSource =" SelectedContent"
75
- ContentStringFormat =" {TemplateBinding ContentStringFormat }"
76
- ContentTemplate =" {TemplateBinding ContentTemplate }"
77
- ContentTemplateSelector =" {TemplateBinding ContentTemplateSelector }"
75
+ ContentStringFormat =" {TemplateBinding SelectedContentStringFormat }"
76
+ ContentTemplate =" {TemplateBinding SelectedContentTemplate }"
77
+ ContentTemplateSelector =" {TemplateBinding SelectedContentTemplateSelector }"
78
78
Focusable =" False"
79
79
SnapsToDevicePixels =" {TemplateBinding SnapsToDevicePixels}" />
80
80
</Border >
You can’t perform that action at this time.
0 commit comments