开发者

Datagrid, first column to be left-justified, the rest be centered

I have a DataGrid, that references another style that sets the property for the ColumnHeaderStyle to be centered.

<Style x:Key="CenterDataGridStyle" TargetType="{x:Type DataGrid}">
                <Style.Setters>                    
                    <Setter Property="ColumnHeaderStyle" Value="{St开发者_如何转开发aticResource CenterColumnHeaderStyle}"/>                    
                </Style.Setters>
            </Style>

Is there a way in the code behind to make the DataGrid have its first column to be left-justified instead of center? I got so far as:

dtGridReads.Columns[0].

then I'm not sure if there was a property I could set for this or not? Thanks.


There is not a single property like HorizontalAlignment that you can set on the column, instead you'll need to construct a Style similar to what you have in XAML, and apply it to the column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜