Skip to content

Commit 956f89d

Browse files
authored
Merge pull request #254 from w-ahmad/feat/unified_fonts
feat: Unify Font Size/Family Across TableView
2 parents 7952c2f + be21b91 commit 956f89d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/TableView.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ protected override void PrepareContainerForItemOverride(DependencyObject element
107107
protected override DependencyObject GetContainerForItemOverride()
108108
{
109109
var row = new TableViewRow { TableView = this };
110-
_rows.Add(row);
111110

111+
// Set bindings for FontFamily and FontSize to propagate from TableView to TableViewRow
112+
row.SetBinding(FontFamilyProperty, new Binding { Path = new("TableView.FontFamily"), RelativeSource = new() { Mode = RelativeSourceMode.Self } });
113+
row.SetBinding(FontSizeProperty, new Binding { Path = new("TableView.FontSize"), RelativeSource = new() { Mode = RelativeSourceMode.Self } });
114+
115+
_rows.Add(row);
112116
return row;
113117
}
114-
118+
115119
/// <inheritdoc/>
116120
protected override async void OnKeyDown(KeyRoutedEventArgs e)
117121
{

src/Themes/TableView.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
<Style x:Key="DefaultTableViewStyle"
1717
TargetType="local:TableView">
18+
<Setter Property="FontFamily"
19+
Value="{ThemeResource ContentControlThemeFontFamily}" />
20+
<Setter Property="FontSize"
21+
Value="{ThemeResource ControlContentThemeFontSize}" />
1822
<Setter Property="IsTabStop"
1923
Value="False" />
2024
<Setter Property="TabNavigation"

src/Themes/TableViewRow.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
TargetType="local:TableViewRow"
1717
win:BasedOn="{StaticResource DefaultListViewItemStyle}"
1818
not_win:BasedOn="{StaticResource ListViewItemExpanded}">
19-
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
20-
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
2119
<Setter Property="Background" Value="{ThemeResource TableViewRowBackground}" />
2220
<Setter Property="Foreground" Value="{ThemeResource TableViewRowForeground}" />
2321
<Setter Property="TabNavigation" Value="Local" />

0 commit comments

Comments
 (0)