XamDataGrid:我有两列(显示十进制数据):我想要一列带有“$”的列标志,一个没有。如何?

发布于 2024-10-20 05:26:51 字数 1583 浏览 1 评论 0原文

我有两个 decimal 数据类型列;我希望它们像这样显示:

  • 前面有“$”符号
  • 第 1 列 (ColumnWithNoDollarSign) 将在值第 2 列 (ColumnWithDollarSign) 值前面会有一个“$”符号

这是我的 XAML 当前的样子:

<ig:XamDataGrid Name="xamDataGrid"                        
                IsGroupByAreaExpanded="False"
                DataSource="{Binding Rows, Mode=OneWay}">
    <ig:XamDataGrid.Resources>
        <Style TargetType="{x:Type Editors:XamNumericEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
        <Style TargetType="{x:Type Editors:XamCurrencyEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
    </ig:XamDataGrid.Resources>
    <ig:XamDataGrid.FieldLayoutSettings>
        <ig:FieldLayoutSettings AutoGenerateFields="False"/>
    </ig:XamDataGrid.FieldLayoutSettings>
    <ig:XamDataGrid.FieldLayouts>
        <ig:FieldLayout Key="layout">
            <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1"/>
            <ig:Field Name="ColumnWithDollarSign" Label="Column 1"/>
        </ig:FieldLayout>
    </ig:XamDataGrid.FieldLayouts>
</ig:XamDataGrid>

据我所知,问题是我应用的 XamCurrencyEditor 样式覆盖了所有 小数 列。我只希望它覆盖 decimal 列之一。我该怎么做呢?

I have two decimal datatype columns; I want them displayed like so:

  • Column 1 (ColumnWithNoDollarSign) will have no "$" sign in front of the values
  • Column 2 (ColumnWithDollarSign) will have a "$" sign in front of the values

This is what my XAML currently looks like:

<ig:XamDataGrid Name="xamDataGrid"                        
                IsGroupByAreaExpanded="False"
                DataSource="{Binding Rows, Mode=OneWay}">
    <ig:XamDataGrid.Resources>
        <Style TargetType="{x:Type Editors:XamNumericEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
        <Style TargetType="{x:Type Editors:XamCurrencyEditor}">
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="FontSize" Value="12" />
        </Style>
    </ig:XamDataGrid.Resources>
    <ig:XamDataGrid.FieldLayoutSettings>
        <ig:FieldLayoutSettings AutoGenerateFields="False"/>
    </ig:XamDataGrid.FieldLayoutSettings>
    <ig:XamDataGrid.FieldLayouts>
        <ig:FieldLayout Key="layout">
            <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1"/>
            <ig:Field Name="ColumnWithDollarSign" Label="Column 1"/>
        </ig:FieldLayout>
    </ig:XamDataGrid.FieldLayouts>
</ig:XamDataGrid>

The problem, as I see it, is that the XamCurrencyEditor style I am applying is overriding all decimal columns. I only want it to override one of the decimal columns. How would I go about doing this?

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

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

发布评论

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

评论(1

薄荷港 2024-10-27 05:26:51

XamNumericEditor 是否表示不带 $ 的格式?如果是这样,您是否可以不只指定每个列使用的样式,即:

<ig:XamDataGrid.FieldLayouts>
    <ig:FieldLayout Key="layout">
        <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1" Style="{StaticResource XamNumericEditor}"/>
        <ig:Field Name="ColumnWithDollarSign" Label="Column 1" Style="{StaticResource XamCurrencyEditor}"/>
    </ig:FieldLayout>
</ig:XamDataGrid.FieldLayouts>

尽管我建议将所有样式信息移动到单个文件(例如 App.xaml),而不是在多个位置重新定义它。

Does the XamNumericEditor represent the format without the $? If so, can you not just specify the style used by each column, ie do:

<ig:XamDataGrid.FieldLayouts>
    <ig:FieldLayout Key="layout">
        <ig:Field Name="ColumnWithNoDollarSign" Label="Column 1" Style="{StaticResource XamNumericEditor}"/>
        <ig:Field Name="ColumnWithDollarSign" Label="Column 1" Style="{StaticResource XamCurrencyEditor}"/>
    </ig:FieldLayout>
</ig:XamDataGrid.FieldLayouts>

Although I would recommend moving all style info to a single file, such as App.xaml, rather than re-defining it in multiple places.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文