Hello Stackies
I'm using a DataGrid inside a StackPanel inside a Grid which causes the GridView to be wider than its preferred size. All the columns are displayed correctly but after the last column the end of the ItemsSource data type name is displayed. Apparently its is drawn in the background and hidden by the columns in the normal case.
I tried to add an empty column with MinWidth="0" and Width="*" but like that the horizontal scrollbar is not displayed if necessary.
How do I hide the data type text?
XAML code:
<Grid Margin="5,5,5,5"
Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="30" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0"
Grid.Column="0"
Orientation="Vertical">
<DataGrid ItemsSource="{Binding BudgetPositions}"
IsSynchronizedWithCurrentItem="True"
AutoGenerateColumns="False"
GridLinesVisibility="None"
HeadersVisibility="Column"
CanUserAddRows="False"
CanUserDeleteRows="False">
<DataGrid.Resources>
</DataGrid.Resources>
<DataGrid.Columns>
<!-- Budget group column -->
<DataGridTemplateColumn Header="Budget Group"
Width="Auto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock DataContext="{Binding GroupName}"
Text="{Binding Value}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- Budget position column -->
<DataGridTemplateColumn Header="Budget Position"
Width="Auto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock DataContext="{Binding PositionName}"
Text="{Binding Value}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Button Content="Add budget position"
x:Name="addPositionButton"
Width="140"
Command="{Binding BudgetPositions.AddNewCommand}" />
</StackPanel>
...
Here's a screenshot of the DataGrid:
Cheers AC