为什么 GridControl 在执行后会创建一个额外的 column/space?

Why GridControl is creating an extra column/space after execution?

DevExpress UI 控件用于 Windows Presentation Foundation(或 WPF)应用程序,我正在尝试 fix/Improve 它。

应用程序中的多个视图包括向用户显示某些数据的网格。网格在设计器中看起来很正常,正常情况下我的意思是列数与所需的相同。然而,在应用程序执行后,每个视图中的每个网格都会生成一个新的 column/space - 空的不可点击且无用。

我尝试了 Grid 的属性,但似乎无法修复它。 AutoGenerateColumns="None"是为整个Grid设置的,每一列的属性都没有可疑之处。我试着查看 DevExpress 文档,但没有帮助,而且很耗时。他们提到 hiding/displaying 东西是如何工作的,但不是自动生成的。

我怎样才能防止这种情况发生?

在编译器中查看:Here

执行后查看:Here

网格XAML:

            <dxg:GridControl x:Name="sessionGrid" SelectedItem="{Binding SelectedSession}" ItemsSource="{Binding Sessions}" AutoGenerateColumns="None" Margin="0,10,0,0" SelectionMode="Row" Grid.Row="2" DesignTimeDataSourceRowCount="15" TouchDown="sessionGrid_TouchDown" MouseDown="sessionGrid_MouseDown" >
            <dxg:GridControl.Columns>
                <dxg:GridColumn x:Name="sessionNameColumn" Header="Name" FieldName="Name" AllowAutoFilter="False" AllowBestFit="True" AllowEditing="False"  AllowConditionalFormattingMenu="False" AllowGrouping="True" AllowMoving="True" MinWidth="5"/>

                <dxg:GridColumn x:Name="sessionTypeColumn" Header="Type" FieldName="Type" AllowAutoFilter="False"  AllowEditing="False"  AllowColumnFiltering="False" AllowConditionalFormattingMenu="False" SortOrder="Ascending" SortIndex="0">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings HorizontalContentAlignment="Left"/>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
                <dxg:GridColumn x:Name="sessionToleranceColumn" Header="Tolerance" FieldName="ToleranceFormatted" AllowAutoFilter="False"  AllowEditing="False"  AllowColumnFiltering="False" AllowConditionalFormattingMenu="False"/>
                <dxg:GridColumn x:Name="sessionDateColumn" Header="Date Created" FieldName="DateCreated" AllowAutoFilter="False" AllowColumnFiltering="False" AllowConditionalFormattingMenu="False" AllowEditing="False" RoundDateTimeForColumnFilter="False">
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings DisplayFormat="G" />
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>

            <dxg:GridControl.View>
                <dxg:TableView x:Name="sessionTable" AllowPerPixelScrolling="True" AllowEditing="False" ShowIndicator="False" AutoWidth="True"  AllowColumnMoving="True" AllowResizing="True" AllowSorting="True" IsColumnMenuEnabled="True" EditorShowMode="MouseUpFocused" IndicatorWidth="70" IsGroupFooterMenuEnabled="False" PrintGroupFooters="False" ShowBandsPanel="False" AllowMasterDetail="False" ShowBandsInCustomizationForm="False" AllowColumnFiltering="False" ShowSearchPanelMode="Never" AllowMoveColumnToDropArea="False">
                    <dxg:TableView.ColumnMenuCustomizations>
                        <dxb:RemoveBarItemAndLinkAction ItemName="{x:Static dxg:DefaultColumnMenuItemNamesBase.ColumnChooser}" />
                    </dxg:TableView.ColumnMenuCustomizations>
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>

.

尝试:

Here it says that I need to put Width = '*' but the compiler is not allowing me to put it, neither in XAML nor in Column Properties, so I tried hard coding column Width and MinWidth as mentioned Here。但是,它仍然无法正常工作。错误是 "Cannot implicitly convert Type System.Windows.GridLength to double"

        private void sessionGrid_Loaded(object sender, RoutedEventArgs e)
    {     
        foreach (DevExpress.Xpf.Grid.GridColumn gridColumn in sessionGrid.Columns)
        {
        // Do something
        gridColumn.MinWidth = ActualWidth;
        gridColumn.Width = new GridLength(1, GridUnitType.Star);
        }
    }

此问题已通过调整和解锁主网格内网格控件的宽度来解决。但是,我们无法找到问题的确切 pattern/cause。因此,通过反复试验修复了它。