tags:

views:

11

answers:

1

How can I apply a static resource by name based upon data? I know that I can write a data trigger for styling properties, but I want to apply an entire style based upon bound data.

Ex:
if (condition) CellValuePresenterStyle="{StaticResource OptionalFieldCellPresenter}" else CellValuePresenterStyle="{StaticResource RequiredFieldCellPresenter}"

A: 

Apply a style to the parent control, it looks like you are using a DataGrid, with a default CellStyleTemplate.

Then in Style.Triggers add a data trigger to swap the style to another style when a condition is met

benPearce
i like the idea, but i think my example might be misleading. if i write a data trigger in the style, then replacing the style will remove the data trigger - right?
not if you give the style a key and use the BasedOn attribute in the new style
benPearce