We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Having a Style for a column would give the user a way to influence the appearance of the cells within a column.
Example:
In this example, the ID-Field is rightjustified, Field2/3 are centered, and Field1 is ...special.
How I did it
1- created a new DP ColumnStyle (of type Style) within TableViewBoundColumn.
ColumnStyle
Style
TableViewBoundColumn
2- modified TableViewTextColumn.GenerateElement(...) (and same way also Date- and NumberColumn)
TableViewTextColumn.GenerateElement(...)
var textBlock = new TextBlock(); textBlock.SetBinding(TextBlock.TextProperty, Binding); if (ColumnStyle != null && ColumnStyle.TargetType == typeof(TextBlock)) textBlock.Style = ColumnStyle; textBlock.Margin = new Thickness(12, 0, 12, 0); // make sure the ColumnStyle doesn't change the Margin return textBlock;
3- The xaml looks like so:
<tab:TableView x:Name="MyTV" Height="450" RowHeight="60" RowMaxHeight="80" Style="{StaticResource LookupTable}" SelectionMode="Single" ItemsSource="{x:Bind ViewModel.Items, Mode=OneWay}" > <tab:TableView.Resources> <Style x:Name="centerTextStyle" TargetType="TextBlock"> <Setter Property="HorizontalTextAlignment" Value="Center" /> <Setter Property="Foreground" Value="Red" /> </Style> <Style x:Name="centerBoldTextStyle" TargetType="TextBlock"> <Setter Property="HorizontalTextAlignment" Value="Center" /> <Setter Property="FontWeight" Value="Bold" /> </Style> <Style x:Name="rightTextStyle" TargetType="TextBlock"> <Setter Property="HorizontalTextAlignment" Value="Right" /> </Style> <Style x:Name="moreTextStyle" TargetType="TextBlock"> <Setter Property="HorizontalTextAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="Foreground" Value="LightCyan" /> <Setter Property="FontFamily" Value="Century Gothic" /> <Setter Property="FontSize" Value="11" /> <Setter Property="FontStyle" Value="Italic" /> <Setter Property="Padding" Value="5 10" /> <Setter Property="MaxHeight" Value="58" /> <Setter Property="TextWrapping" Value="WrapWholeWords" /> <Setter Property="TextTrimming" Value="CharacterEllipsis" /> </Style> </tab:TableView.Resources> <tab:TableView.Columns> <tab:TableViewNumberColumn Header="ID" Width="30" Binding="{Binding ItemId}" ColumnStyle="{StaticResource rightTextStyle}" /> <tab:TableViewTextColumn Header="Field 1" Width="180" Binding="{Binding ItemName}" ColumnStyle="{StaticResource moreTextStyle}" /> <tab:TableViewTextColumn Header="Field 2" Width="100" Binding="{Binding ItemIntValue}" ColumnStyle="{StaticResource centerTextStyle}"/> <tab:TableViewDateColumn Header="Field 3" Width="100" Binding="{Binding ItemDate}" ColumnStyle="{StaticResource centerBoldTextStyle}"/> </tab:TableView.Columns> </tab:TableView>
Other Ideas
we could have the numberColumn right-aligned by default, the user could overwrite that with the style.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Having a Style for a column would give the user a way to influence the appearance of the cells within a column.
Example:
In this example, the ID-Field is rightjustified, Field2/3 are centered, and Field1 is ...special.
How I did it
1- created a new DP
ColumnStyle
(of typeStyle
) withinTableViewBoundColumn
.2- modified
TableViewTextColumn.GenerateElement(...)
(and same way also Date- and NumberColumn)3- The xaml looks like so:
Other Ideas
we could have the numberColumn right-aligned by default, the user could overwrite that with the style.
The text was updated successfully, but these errors were encountered: