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
595
Dynamic DataTriggers
posted

Hi,

I would like to generally define my styles in the XAML, but add dynamic datatriggers on top in code-behind.

What I have in the xaml is like

         <igDP:XamDataGrid.Resources>

            <Style TargetType="{x:Type igDP:CellValuePresenter}">

                    <Setter Property="Background" Value="CadetBlue" />

            </Style>

        </igDP:XamDataGrid.Resources>

 

Somewhere in the code behind, I'd want to add, for example:

 

var dt = new DataTrigger

{

              Binding = new Binding(bindingPath),

              Value = true

};

dt.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(1)));

dt.Setters.Add(new Setter(Control.BorderBrushProperty, Brushes.Green));

I have tried all sorts of permutations, without luck.  For example, capturing RecordsInViewChanged and creating a new style based on  CellValuePresenter.FromRecordAndField, or trying to play with field.Settings.CellValuePresenterStyle.  
Please Help!

Parents Reply Children