保持多个devexpress网格的列大小同步

时间:2019-09-09 11:12:21

标签: wpf xaml devexpress-wpf devexpress-gridcontrol

我在wpf应用程序中有一个页面,其中有一个通过项目控件呈现的多个devexpress网格(Grid1,Grid2,Grid3等),并希望确保其列(Column1,Column2,Column3)呈现相同的状态最初的宽度。例如:Column1在Grid1,Grid2和Grid3中始终具有相同的宽度,而Column2在Grid1,Grid2和Grid3中始终具有相同的宽度,无论它们显示什么数据。

我该如何实现?

            <ItemsControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                      x:Name="Grids" Margin="-5,0,0,0"
                      ItemsSource="{Binding Items, Mode=TwoWay}" 
                      Background="Transparent"
                      BorderThickness="0"
                      Grid.IsSharedSizeScope="True"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                      ScrollViewer.VerticalScrollBarVisibility="Auto">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="1" BorderBrush="Black" Margin="10,5,0,25" Width="Auto" MinWidth="750">
                                <dxg:GridControl MaxHeight="250" MinHeight="100" MinWidth="700"
                                                 ItemsSource="{Binding Statuses}"                                                   
                                                 AutoGenerateColumns="None" SelectionMode="None">
                                    <dxg:GridControl.Columns>
                                        <dxg:GridColumn Header="Column1" FieldName="Field1" UnboundType="Object" SortIndex="0" AllowSorting="True"  ReadOnly="True" />
                                        <dxg:GridColumn Header="Column2" FieldName="Field2" UnboundType="Object" ReadOnly="True"  SortIndex="1" SortMode="Value" Binding="Field2" />
                                    </dxg:GridControl.Columns>
                                </dxg:GridControl>
                                <!-- Code left out for brewity sake... -->
                        </Border>
                    </DataTemplate>                        
                </ItemsControl.ItemTemplate>
            </ItemsControl>

0 个答案:

没有答案