Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
710
Background Color to LabelPresenter
posted

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

Parents
No Data
Reply
  • 295
    posted

    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>


               

Children