Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DataGrid column style -> can't get what I want...

$
0
0

Hi,

Somehow I can't figure out how to set the DataGrid so it shows columns which are not readonly in other background color.

What I currently get:

What happens if I select a editable cell:

What I would like to have is that the "editable cells are completely colored yellow (not only the text) and that the content of the cells stays visible when selecting a cell.

this is my XAML:

<UserControl.Resources><Style TargetType="{x:Type DataGridCell}"><Setter Property="HorizontalAlignment" Value="Right" /><Style.Triggers><Trigger Property="IsReadOnly" Value="False"><Setter Property="Background" Value="Yellow" /></Trigger></Style.Triggers></Style></UserControl.Resources><DataGrid ItemsSource="{Binding Steps, Mode=TwoWay}" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" HeadersVisibility="Column" SelectionMode="Single" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" HorizontalAlignment="Left" Margin="0,0,2,0" ><DataGrid.ContextMenu><ContextMenu><MenuItem Header="Neu Zeile" Command="{Binding AddNewStepCommand}"/><MenuItem Header="Zeile löschen"/></ContextMenu></DataGrid.ContextMenu><DataGrid.VerticalGridLinesBrush><SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveBorderColorKey}}"/></DataGrid.VerticalGridLinesBrush><DataGrid.HorizontalGridLinesBrush><SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveBorderColorKey}}"/></DataGrid.HorizontalGridLinesBrush><DataGrid.Columns><DataGridTextColumn Binding="{Binding LoadStep}" ClipboardContentBinding="{x:Null}" Header="Lastenstufe i" IsReadOnly="True"/><DataGridTextColumn Binding="{Binding Amplitude}" ClipboardContentBinding="{x:Null}" Header="Hub [mm]" IsReadOnly="True"/><DataGridTextColumn Binding="{Binding RelativAmplitude, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ClipboardContentBinding="{x:Null}" Header="X/Xmax [%]"/><DataGridTextColumn Binding="{Binding SpectrumSum}" ClipboardContentBinding="{x:Null}" Header="Kollektiv" IsReadOnly="True"/><DataGridTextColumn Binding="{Binding RequiredLoadCycles}" ClipboardContentBinding="{x:Null}" Header="Häufigkeit"/><DataGridTextColumn Binding="{Binding Order}" ClipboardContentBinding="{x:Null}" Header="Reihenfolge"/></DataGrid.Columns></DataGrid>

Thanks for any hints or help!

Regards
Rainer


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>