|
private void treeGrid_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
var treeGrid = sender as SfTreeGrid;
TreeGridRowInfo removedRowInfo = null;
TreeGridRowInfo addedRowInfo = null;
if (e.AddedItems.Count > 0)
addedRowInfo = e.AddedItems[0] as TreeGridRowInfo;
if (e.RemovedItems.Count > 0)
removedRowInfo = e.RemovedItems[0] as TreeGridRowInfo;
treeGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
{
TreeDataRowBase removedRow = null;
TreeDataRowBase addedRow = null;
if (addedRowInfo != null)
addedRow = treeGrid.GetTreeGridRowGenerator().Items.FirstOrDefault(r => r.RowIndex == addedRowInfo.RowIndex);
if (removedRowInfo != null)
removedRow = treeGrid.GetTreeGridRowGenerator().Items.FirstOrDefault(row => row.RowIndex == removedRowInfo.RowIndex);
if (addedRow != null)
{
var addedrowControl = addedRow.Element as TreeGridRowControl;
var textBox = GridUtil.FindDescendantChildByType(addedrowControl, typeof(TextBox)) as TextBox;
if (textBox != null)
textBox.Foreground = new SolidColorBrush(Colors.White);
else
{
var label = GridUtil.FindDescendantChildByType(addedrowControl, typeof(Label)) as Label;
if (label != null)
label.Foreground = new SolidColorBrush(Colors.White);
}
}
if (removedRow != null)
{
var removedRowControl = removedRow.Element as TreeGridRowControl;
var textBox = GridUtil.FindDescendantChildByType(removedRowControl, typeof(TextBox)) as TextBox;
if (textBox != null)
textBox.Foreground = new SolidColorBrush(Colors.Black);
else
{
var label = GridUtil.FindDescendantChildByType(removedRowControl, typeof(Label)) as Label;
if (label != null)
label.Foreground = new SolidColorBrush(Colors.Black);
}
}
}));
} |