0

I am rather new to WPF. On .NET 3.5 using C# I want to build a WPF application including Syncfusion's GridDataControl in a TabItem. The GridDataControl is supposed to auto-resize by specifying the column width in multiples of '*'. This works fine after the first start of the app. But after switching tabs and again switching back resizing is broken and the grid control remains fixed in size. Here is my xaml code:

<Window x:Class="SyncfusionGridData.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:SyncfusionGridData"
    xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
    mc:Ignorable="d"
    Title="MainWindow" Height="500" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
    <TabControl>
        <TabItem Header="Tab1">
            <Grid Name="layoutRoot">
                <syncfusion:GridDataControl x:Name="dataGrid" 
                                            AutoPopulateColumns="False"
                                            ShowAddNewRow="False"
                                            ItemsSource="{Binding GDCSource}">

                    <syncfusion:GridDataControl.VisibleColumns>
                        <syncfusion:GridDataVisibleColumn Width="*"
                                                          HeaderText="ContactName"
                                                          MappingName="ContactName">
                        </syncfusion:GridDataVisibleColumn>
                        <syncfusion:GridDataVisibleColumn Width="*"
                                                          HeaderText="ContactTitle"
                                                          MappingName="ContactTitle">
                        </syncfusion:GridDataVisibleColumn>
                    </syncfusion:GridDataControl.VisibleColumns>
                </syncfusion:GridDataControl>
            </Grid>
        </TabItem>
        <TabItem Header="Tab2">
            <Label Content="2" />
        </TabItem>
    </TabControl>
</Grid>

where 'GDCSource' is an ObservableCollection of 'Person' and 'Person' has the properties 'ContactName' and 'ContactTitle'.

I tried using Syncfusion's own tab control (TabControlExt) but this shows the same behaviour. Not specifying the ItemsSource property and displaying only the header row shows proper resizing.

I do not really have an idea what this might be related to. Thanks for any help!

troet
  • 23
  • 6

1 Answers1

0

AutoSizing fails as soon as the GridDataControl is Unloaded. Add the following property to your TabControlExt to prevent Unloading of the Tabs after they have been loaded.

IsDisableUnloadTabItemExtContent="True"
pfeigl
  • 457
  • 5
  • 12