<syncfusion:TreeGridTextColumn HeaderText="Key" MappingName="Key" Width="100" AllowFocus="True" AllowEditing="False" >
<syncfusion:TreeGridTextColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="VSIcons/Field_16x.png" Width="15" Margin="5,0,0,0"/>
<TextBlock Text="{Binding Key}" Margin="7,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</syncfusion:TreeGridTextColumn.CellTemplate>
</syncfusion:TreeGridTextColumn> |
public MainWindow()
{
InitializeComponent();
treeGrid.CurrentCellBeginEdit += TreeGrid_CurrentCellBeginEdit;
}
private void TreeGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.TreeGrid.TreeGridCurrentCellBeginEditEventArgs e)
{
var treeNode = treeGrid.View.GetNodeAt(e.RowColumnIndex.RowIndex - 1);
if (treeNode.HasChildNodes)
{
var data = treeNode.Item as PersonInfo;
e.Cancel = !data.LikesCake;
}
} |
public MainWindow()
{
InitializeComponent();
treeGrid.CurrentCellBeginEdit += TreeGrid_CurrentCellBeginEdit;
}
private void TreeGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.TreeGrid.TreeGridCurrentCellBeginEditEventArgs e)
{
var rows = treeGrid.GetType().GetField("RowGenerator", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(treeGrid);
List<TreeDataRowBase> treeGridRows = (rows as TreeGridRowGenerator).Items;
var treeGridRow = treeGridRows.FirstOrDefault(row => row.RowIndex == e.RowColumnIndex.RowIndex);
if (treeGridRow == null)
return;
var column = treeGridRow.VisibleColumns[e.RowColumnIndex.ColumnIndex];
if (column == null)
return;
if (column.Element is TreeGridExpanderCell && treeGridRow.Node.HasChildNodes)
{
var data = treeGridRow.RowData as PersonInfo;
e.Cancel = !data.LikesCake;
}
}
|