I am dynamically generating field layouts from c# and I currently have a trigger setup to color the background of a CellValuePresenter when certain conditions are meet, the issue is that I am using Office2k7Silver theme, but when I set a custom style on the CellValuePresenter I don't know how to tell it to base the style on the style defined for that theme, it works but uses the default style instead of the theme style. Does anyone know how to access a certain style from a theme?
Style cellstyle = new Style(typeof(CellValuePresenter), DataPresenterOffice2k7Silver.Instance.Resources["CellValuePresenter"].???); //How to get the style?
DataTrigger pTrigger = new DataTrigger();
pTrigger.Binding = new Binding() { Path = new PropertyPath("DataItem.Fields[" + index + "].MatchesPeriodicity") };
pTrigger.Value = false;
pTrigger.Setters.Add(new Setter(CellValuePresenter.BackgroundProperty, Brushes.DarkGray));
cellstyle.Triggers.Add(pTrigger);
DataTrigger dataTrigger = new DataTrigger();
dataTrigger.Binding = new Binding() { Path = new PropertyPath("DataItem.Fields[" + index + "].HasNewData") };
dataTrigger.Value = true;
dataTrigger.Setters.Add(new Setter(CellValuePresenter.BackgroundProperty, Brushes.LightGreen));
cellstyle.Triggers.Add(dataTrigger);
field.Settings.CellValuePresenterStyle = cellstyle;
Here is a sample syntax on how to base a style on the one in the theme:
<Style TargetType="{x:Type igDP:DataRecordCellArea}" BasedOn="{x:Static themes:DataPresenterLunaNormal.DataRecordCellArea}">
Was simpler than I thought:
Style cellstyle = new Style(typeof(CellValuePresenter), DataPresenterOffice2k7Silver.CellValuePresenter);