Hi,
I want to give Background Color to LabelPresenter when a
1) field with in a column is selected
2) When that particular Label Presenter is selected.
I think this needs to be done at codebehind so basically I need to know that how can we find the Label Presnter when a particulkar field is selected.
Thanks
Sumeet
here what you can do
code behind.
Style style = new Style(typeof(CellValuePresenter)); Debug.WriteLine("Creating Style"); DataTrigger trigger = new DataTrigger()
DataTrigger selectedtrigger = new DataTrigger() { Binding = new Binding("IsSelected") { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DataRecordCellArea), 1) }, Value = true }; selectedtrigger.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.White)); style.Triggers.Add(selectedtrigger); xamDataGrid1.FieldSettings.CellValuePresenterStyle = style;
or in XAML
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:DataRecordCellArea}}, Path=IsSelected}" Value="True"> <Setter Property="Background" Value="Red" /> </DataTrigger> </Style.Triggers> </Style>
Thanks for the reply, but my requirement is setting the background color on the field header i.e. label presenter when a cell in a column is selected not setting the color on the cell value presenter.