I am using Syncfusion's SfDataGrid instead of standard one, but this question is more about XAML, not the control itself, I think.
So, I have a window with DataGrid. If there is for example 60 records, then the window gets really tall. I want the window not to change its size at all. And really don't know why it's happening.
This is my XAML:
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid Grid.Column="0"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <StackPanel Margin="10,0,10,0" Grid.Row="0" DataContext="{Binding Info}"> <TextBlock Text="Amount:"/> <sf:CurrencyTextBox Value="{Binding Amount}" Margin="0,0,0,10"/> <!-- some other controls --> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource LeftLabel}" Text="Count:"/> <sf:UpDown Grid.Column="1" Grid.Row="0" Margin="0,0,0,5" Value="{Binding Count}"/> <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource LeftLabel}" Text="Year count:"/> <sf:UpDown Grid.Column="1" Grid.Row="1" Value="{Binding YearCount}"/> </Grid> </StackPanel> <Button Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,10,10,5" Content="Simulate >>" Command="{Binding SimulateCommand}"/> </Grid> <!-- This is right part of the window with datagrid --> <DockPanel Grid.Column="1"> <WrapPanel DockPanel.Dock="Top"> <TextBlock Margin="10" Text="Total amount:" /> <TextBlock Text="{Binding TotalAmount"/> </WrapPanel> <!-- and the datagrid --> <sf:SfDataGrid AutoGenerateColumns="False" AllowDeleting="False" AllowEditing="False" IsReadOnly="False" AllowGrouping="False" AllowFiltering="False" ItemsSource="{Binding History}"> <sf:SfDataGrid.Columns> <sf:GridDateTimeColumn DisplayBinding="{Binding Date}" MappingName="PaymentDay" HeaderText="Date"/> <sf:GridCurrencyColumn DisplayBinding="{Binding Amount}" MappingName="PayAmount" HeaderText="Amount"/> </sf:SfDataGrid.Columns> </sf:SfDataGrid> </DockPanel> </Grid>
So what is wrong with it?
(subquestion - how to format text as source code here?)
Query |
Answer | |
I have a window with DataGrid. If there is for example 60 records, then the window gets really tall. I want the window not to change its size at all. And really don't know why it's happening |
We have analyzed your query. It seems that your requirement is to restrict the height of window and this can be achieved by setting Window.Height property. Please refer to the below code snippet
Please refer to the sample in the below link
Sample Link:
Please let us know, if we misunderstood your requirement.
| |
Subquestion – how to format text as source code here? |
We are not clear with your requirement. We suspect that your requirement is to apply formatting for the columns in DataGrid. Please find below KB articles and UG links to know more details
KB articles:
UG Links:
Could you let us know with more details on query with images/ video illustration? It will helps us to investigate further and provide earlier prompt solution. |