We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SfDataGrid - infinite height

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?)

3 Replies

FP Farjana Parveen Ayubb Syncfusion Team July 4, 2019 09:39 AM UTC

Hi Adam, 
  
Thank you contacting Syncfusion support. 
  
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 
  
<Window 
    x:Class="SfDataGridDemo.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:sf="http://schemas.syncfusion.com/wpf" 
   xmlns:interactivity="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:local="clr-namespace:SfDataGridDemo" 
    Title="SfDataGrid Demo" 
    Height="600" 
    Icon="App.ico" 
    WindowStartupLocation="CenterScreen"> 
  
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. 
  
Regards, 
Farjana Parveen A 



AD Adam July 5, 2019 10:38 AM UTC

Hi, thanks for answer. But is this the REAL solution? Or just workaround to a some problem? Should I always specify window height in WPF?


FP Farjana Parveen Ayubb Syncfusion Team July 6, 2019 10:18 AM UTC

Hi Adam, 
 
We have analyzed your query. You can able set the size for the window, based on the size the window is displayed in UI. Otherwise default size is calculated and display, but this is not related to our Syncfusion controls.  
Please find the below links 
 
Regards, 
Farjana Parveen A 


Loader.
Live Chat Icon For mobile
Up arrow icon