'Not get autofit based on maximum length cell width to all other columns in xaml grid
I am Using treeview in XAML. Inside the treeview item am having 3 grid columns. First Column in logo which is common width. but second and third column width is based on text which is binding from backend. The second column not resizing based on max width cell that particular column based on rows values.
I want this file location text (Gray text) start at same position based on previous column max cell width. Below is my code
<HierarchicalDataTemplate
<Grid Grid.IsSharedSizeScope="True" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="a"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" SharedSizeGroup="b"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" SharedSizeGroup="c"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Width="12" Margin="0,0,4,0" Height="auto" Source="img.png""/>
<TextBlock Grid.RowSpan="5" Grid.Column="1" Text="{Binding kmkmkmkm}" Margin="0,7,0,0" Height="20" FontSize="12">
</TextBlock>
<TextBlock Grid.Column="2" Text="{Binding loc}" Margin="10,7,0,0" Height="20" FontSize="12" Foreground="Gray">
</TextBlock>
</Grid>
</HierarchicalDataTemplate>
Suggest me on this.
Solution 1:[1]
After analyzing many solution, found we cannot share like this with shared size scope.
<HierarchicalDataTemplate>
<Grid Name="Grid2" HorizontalAlignment="Left" Grid.IsSharedSizeScope="True">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Width="250">
</StackPanel>
<TextBlock HorizontalAlignment="Left" Width="Auto" VerticalAlignment="Center" Grid.Column="2">
</TextBlock>
</Grid>
</HierarchicalDataTemplate>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sasi Dhivya |

