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
490
CellValuePresenter style is being overridden when a new field is created with its own style
posted

I need help using the CellValuePresenter with the xamDataGrid. I am setting a style in my Grid.Resources like this:

<igDP:XamDataGrid.Resources>

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

                 <Setter Property="Background">

                          <Setter.Value>

                                   <Binding Converter="{StaticResource bconv}" RelativeSource="{RelativeSource self}" Path="Field.Name" />

                          </Setter.Value>

                 </Setter>

                 <Setter Property="HorizontalContentAlignment" Value="Right"/>

                 <EventSetter Event="MouseLeave" Handler="CellPresenter_MouseLeave"/>

                 <EventSetter Event="MouseEnter" Handler="CellPresenter_MouseEnter"/>

         </Style>

</igDP:XamDataGrid.Resources>

 

The details here are not too important other than the fact that it works as expected. The issue occurs when I add a new unbound field dynamically through code and need to change that field’s settings based on parameter only present during runtime. I’m doing this through a CellValuePresenterStyleSelector like this:

 

field.Settings.CellValuePresenterStyleSelector = new CVPStyleSelector_Field(RegularStyle, EditedStyle);
 

where I decide which style to use based on values in my Style Selector. This basically only deals with how the label itself is formatted. Again this works well, except it overrides my previous CellValuePresenter. I tried adding the same properties as I had in my first Style but this would only set the style on the label of the cell and not the entire cell as required. For example the background was only set behind the label but not filling the entire cell. I got closer by changing my background and mouse events into a CellPresenter instead of the CellValuePresenter but I still wasn’t able to get the style as required.

 

Is there a way to have a CellValuePresenter set for the entire grid and then have a different CellValuePresenter set for just the label but not override the first style?

 

Thanks

Parents Reply Children