'Grid not presenting data in colums used in HierarchicalDataTemplate
I used a Grid to present a FileInDirNC type, but the ColumDefinitions doesn't seem to work?
I think it has something to do with HorizontalContentAlignment = "Stretch", but where is it needed? I want to left align the filenames and right align the dates in the Grid.
<TreeView Grid.Row="2" Grid.Column="3" ItemsSource="{Binding RootNC}" Style="{StaticResource TreeViewOrange}" AllowDrop="True"
cal:Message.Attach="[Event Drop] = [Action FileDropped($eventArgs)]; [Event PreviewDragOver] = [Action FilePreviewDragEnter($eventArgs)]" Background="Transparent">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type Model:DirectoryNC}"
ItemsSource="{Binding Children}">
<TextBlock Text="{Binding DirectoryName}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type Model:FileInDirNC}">
<Grid Margin="1" Background="{Binding CreationTime,Converter={StaticResource CreationTimeToBrushConverter}}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column ="0" Text="{Binding FileName}" Margin="5,0,20,0" />
<TextBlock Grid.Column ="1" Text="{Binding CreationTime,StringFormat='{}{0:d/M/yyyy, hh:mm:ss}'}" FontSize="10" TextAlignment="Right"/>
</Grid>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
Kind Regards
Johan
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

