0
私はUIの人ではありませんが、私は単純なことであるように見えました。スタイルが既に設定されているときにDataGridCellの背景色を変更しますか?
すでに確立されている作業用データグリッドの列の背景を変更して、ユーザーの言う内容がわかりやすくなるようにする必要があります。読んだものすべてが<Style TargetType="DataGridCell">
を使用することを指します。これは意味があり、簡単に実行可能ですが、スティがすでに別のターゲットに適用されており、別のターゲットを追加できません。
スタイルが既に設定されている場合、DataGridCellの背景色を変更するにはどうすればよいですか?
これは、いずれかの列が今
<DataGridTextColumn x:Name="colGoalPercentCases" u:XAMLProperties.GroupName="Cases" Width="*" IsReadOnly="False"
Binding="{Binding Path=GoalPercent_Cases, TargetNullValue='', Mode=TwoWay, StringFormat='{}{0:#,#.00\\%;-#,#.00\\%}',NotifyOnTargetUpdated=True}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="{x:Type TextBox}">
<EventSetter Event="LostFocus" Handler="GoalLostFocus" />
<EventSetter Event="LostKeyboardFocus" Handler="GoalLostKeyboardFocus" />
</Style>
</DataGridTextColumn.EditingElementStyle>
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<Grid MinWidth="{Binding Path=ActualWidth, ElementName=colGoalPercentCases}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Content="CS %" Margin="1,0,10,0" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"/>
<TextBox x:Name="tbCasePercent" Margin="1,0,10,0" IsReadOnly="True" Grid.Row="1" Grid.Column="0" Width="Auto" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right"/>
</Grid>
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
</DataGridTextColumn>
EDIT次のようになります。セルスタイルのための追加コード -
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="Background" Value="#FFC7D9FF"/>
</Style>
</DataGridTextColumn.CellStyle>
はいああ、を追加するために必要な重要な要素でした。どうもありがとうございます –
Jmyster