hi,
i try to add style to my CellValuePresenterStyle with C# .
But when this run :
foreach (var _cellTab in _tabCell) { Style _styleCellPresent = _cellTab.Field.Settings.CellValuePresenterStyle; Style _styleSurligne = (Style)dcPnl.FindResource("Surligne"); for (int i = 0; i < _styleSurligne.Setters.Count; i++) { _styleCellPresent.Setters.Add(_styleSurligne.Setters[i]); } }
I have an exception :
InvalidOperationEception
"PresentationFramework"
After a 'SetterBaseCollection is in use (sealed), it can not be changed.
I have the Add methode to the Setters why i don't add style ?
what is the probleme and how to circumvent the problem ?
thanks,
Nathalie
Thanks josh
but how change the background color of a cell programmatically ?
why the AssociatedCellValuePresenter is not accessible , it will be more simple for change the back color, border and other .. ?
thank ,
Hi,
For me whith this code , it work wery well :
gridContrat.ActiveCell = ((DataRecord)this.gridContrat.ViewableRecords[0]).Cells[1];
{
value.Foreground =Brushes.Red;
}
value = CellValuePresenter.FromCell(((DataRecord)this.gridContrat.ViewableRecords[0]).Cells[2]);
value.Foreground = Brushes.Red;
but i have declare all the Field in XAML like this :
<igDP:Field Name="Id" Visibility="Collapsed" />
<igDP:Field Name="Nom" Label="Contrat">
<igDP:Field.Settings>
<igDP:FieldSettings CellWidth="60" CellMaxWidth="80" CellMinWidth="60" >
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="Qtt1" Label="6-7h" >
<igDP:FieldSettings CellWidth="60" CellMinWidth ="60" CellMaxWidth="60" >
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}" >
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Cells[2].Tag}" Value="comment">
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="1,1,1,1"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
<igDP:Field Name="HrQtt1" Visibility="Collapsed" />
<igDP:Field Name="CommentQtt1" Visibility="Collapsed"/>
have you declare the field ?
enjoy
Naathalie
The functianality i want to achieve is to change the font and color of first record.
But the reference of value is only valid in Loaded event of the Grid.
The following code works
void dpReturnGroup_Loaded(object sender, RoutedEventArgs e)
BrushConverter objBrushConverter = new BrushConverter();
FontStyleConverter objFontStyleConverter = new FontStyleConverter();
the following code doesnt work. The value is null all the time.
value = CellValuePresenter.FromCell(((DataRecord)this.dpReturnGroup.ViewableRecords[0]).Cells[1]);
value.Foreground = (Brush)objBrushConverter.ConvertFromString("#FFB9B9B9");
thank you very very much josh.
you are my saveguard :)
i don't see this point :)
I
You can get the CellValuePresenter for a Cell like this:
CellValuePresenter cvp = CellValuePresenter.FromCell(someCell);
josh