【问题标题】:Changing FlowDirection of a cell in Wpf's DataGrid在 Wpf 的 DataGrid 中更改单元格的 FlowDirection
【发布时间】:2011-05-09 19:48:35
【问题描述】:

我有一个 DataGrid,其 FlowDirection 设置为“RightToLeft”。问题是当显示负数时,减号显示在对面。 将单元格本身的 FlowDirection 设置为“LeftToRight”修复它,但是单元格的左边框向右移动,所以我左边没有边框,右边有双边框。 我该如何解决这个问题?

【问题讨论】:

    标签: wpf datagrid wpftoolkit wpfdatagrid


    【解决方案1】:

    您必须在 TextBox 而不是 DataGridCell 上设置 FlowDirection。如果您使用的是 DataGridTextColumn,那么

    <DataGridTextColumn ...>
        <DataGridTextColumn.ElementStyle>
            <Style TargetType="TextBlock">
                <Setter Property="FlowDirection" Value="LeftToRight" />
            </Style>
        </DataGridTextColumn.ElementStyle>
        <DataGridTextColumn.EditingElementStyle>
            <Style TargetType="TextBox">
                <Setter Property="FlowDirection" Value="LeftToRight" />
            </Style>
        </DataGridTextColumn.EditingElementStyle>
    </DataGridTextColumn>
    

    【讨论】:

    • 感谢梅莱克!现在我使用 DataGridTemplateColumn 而不是 TextColumn,这解决了这个问题,但我更喜欢使用 TextColumn。我试试看。
    猜你喜欢
    • 2013-07-20
    • 2023-03-28
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 2018-09-26
    • 2011-06-29
    • 1970-01-01
    相关资源
    最近更新 更多