Hi,
My need is to update the style of a cell. I use a style selector:
protected override Style SelectStyleCore(object item, DependencyObject container)
{
if(container is TreeGridCell && ((TreeGridCell)container).Content is TextBlock)
{
TextBlock textBlock = ((TreeGridCell)container).Content as TextBlock;
string cellText = textBlock.Text;
if (EqualsToZero(item, container))
{
return App.Current.Resources["cellStyleZero"] as Style;
}
if (item is Group || item is GroupComponent)
{
return App.Current.Resources["cellStyleBold"] as Style;
}
}
return App.Current.Resources["cellStyle"] as Style;
}
But I noticied this code is not fired when I edit the cell. How can I refresh the style when I edit? I tried this:
private void TreeGridLines_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e)
{
try
{
if (((SfTreeGrid)sender).CurrentItem is Group)
{
Group group = (Group)((SfTreeGrid)sender).CurrentItem;
saveGroup.ModifyElt(new Group(group));
}
else if (((SfTreeGrid)sender).CurrentItem is Line)
{
Line line = (Line)((SfTreeGrid)sender).CurrentItem;
UpdateFields(line);
saveLine.ModifyElt(new Line(line));
}
treeGridLines.View.Refresh();
}
catch(Exception ex)
{
}
}
But treegrid collaps all nodes and focus is lost.