如何将数据网格中的列宽度设置为 *

发布于 2024-11-30 21:43:59 字数 1785 浏览 1 评论 0原文

我的数据网格只有几列,我希望其中一列始终填充该数据网格的空白空间。我如何更改此代码以获得此结果?不幸的是这不是我的代码

<data:DataGrid
                            x:Name="grdArchive" 
                            Grid.Row="0" 
                            Visibility="Visible"  
                            Style="{StaticResource DGrid}"
                            ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
                            RowStyle="{StaticResource DataGridRowStyle}"
                            GridLinesVisibility="Horizontal"
                            SelectionMode="Single"
                            AutoGenerateColumns="False" 
                            Background="#FFFFFF"
                            VerticalAlignment="Stretch" 
                            HorizontalAlignment="Stretch"
                            IsReadOnly="True"
                            CanUserResizeColumns="False"
                            LoadingRow="grdMessages_LoadingRow">
            <data:DataGrid.Columns>


                <!-- COLUMN: ESCALATE TYPE ID -->
                <data:DataGridTemplateColumn CanUserSort="True"
                                             SortMemberPath="EscalateTypeId">
                    <data:DataGridTemplateColumn.CellTemplate>

                        <DataTemplate>
                            <TextBlock Text="{Binding EscalateTypeId, Converter={StaticResource cnvMessagingStrings}, ConverterParameter=2}" 
                                       VerticalAlignment="Center"
                                       Margin="5,0,5,0"/>
                        </DataTemplate>

                    </data:DataGridTemplateColumn.CellTemplate>

                </data:DataGridTemplateColumn>

I have got datagrid with few columns, and I want to have one of them always fill empty space of this datagrid. Hwo can I change this code to have this result? Unfortunately this is not my code

<data:DataGrid
                            x:Name="grdArchive" 
                            Grid.Row="0" 
                            Visibility="Visible"  
                            Style="{StaticResource DGrid}"
                            ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
                            RowStyle="{StaticResource DataGridRowStyle}"
                            GridLinesVisibility="Horizontal"
                            SelectionMode="Single"
                            AutoGenerateColumns="False" 
                            Background="#FFFFFF"
                            VerticalAlignment="Stretch" 
                            HorizontalAlignment="Stretch"
                            IsReadOnly="True"
                            CanUserResizeColumns="False"
                            LoadingRow="grdMessages_LoadingRow">
            <data:DataGrid.Columns>


                <!-- COLUMN: ESCALATE TYPE ID -->
                <data:DataGridTemplateColumn CanUserSort="True"
                                             SortMemberPath="EscalateTypeId">
                    <data:DataGridTemplateColumn.CellTemplate>

                        <DataTemplate>
                            <TextBlock Text="{Binding EscalateTypeId, Converter={StaticResource cnvMessagingStrings}, ConverterParameter=2}" 
                                       VerticalAlignment="Center"
                                       Margin="5,0,5,0"/>
                        </DataTemplate>

                    </data:DataGridTemplateColumn.CellTemplate>

                </data:DataGridTemplateColumn>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时常饿 2024-12-07 21:43:59

为 DataGridTemplateColumn 之一设置 Width="*"

<data:DataGridTemplateColumn CanUserSort="True"
                                SortMemberPath="EscalateTypeId"
                                Width="*">

Set Width="*" for one of your DataGridTemplateColumn.

<data:DataGridTemplateColumn CanUserSort="True"
                                SortMemberPath="EscalateTypeId"
                                Width="*">
情归归情 2024-12-07 21:43:59

我希望有一个与以下内容等效的 silverlight

dataGridView1.AutoGenerateColumns = false;
DataGridViewColumn column = new DataGridViewColumn();
        column.DataPropertyName = "Question Number";
        column.HeaderText = "Question Number";
        column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns.Add(column);

    // Summary:
    //     The column width adjusts so that the widths of all columns exactly fills
    //     the display area of the control, requiring horizontal scrolling only to keep
    //     column widths above the System.Windows.Forms.DataGridViewColumn.MinimumWidth
    //     property values. Relative column widths are determined by the relative System.Windows.Forms.DataGridViewColumn.FillWeight
    //     property values.

I hope there is a silverlight equivalent of the following

dataGridView1.AutoGenerateColumns = false;
DataGridViewColumn column = new DataGridViewColumn();
        column.DataPropertyName = "Question Number";
        column.HeaderText = "Question Number";
        column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns.Add(column);

    // Summary:
    //     The column width adjusts so that the widths of all columns exactly fills
    //     the display area of the control, requiring horizontal scrolling only to keep
    //     column widths above the System.Windows.Forms.DataGridViewColumn.MinimumWidth
    //     property values. Relative column widths are determined by the relative System.Windows.Forms.DataGridViewColumn.FillWeight
    //     property values.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文