小编Sub*_*bru的帖子

LayoutTransform应用于DataGridCell内容时的性能问题

我有一个自定义数据网格,其单元格的样式如下所示

<Style x:Key="CellStyleBase"
           TargetType="{x:Type DataGridCell}">
        <Setter Property="Visibility"
                Value="Visible" />
        <Setter Property="Background"
                Value="{Binding RelativeSource={RelativeSource Self}, Path=Column.Header.CellBackground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Grid x:Name="BackgroundGrid"
                          Background="{TemplateBinding Background}">
                        <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}},Path=Content.Text}"
                                   HorizontalAlignment="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}},Path=Column.Header.CellHorzontalAlignment}"
                                   VerticalAlignment="Center"
                                   FontWeight="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}},Path=Column.Header.CellFontWeight}"
                                   Margin="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}},Path=Content.Margin}"
                                   Padding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}},Path=Content.Padding}" />
                        <Grid.LayoutTransform>
                            <TransformGroup>
                                <RotateTransform Angle="-90" />
                            </TransformGroup>
                        </Grid.LayoutTransform>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
Run Code Online (Sandbox Code Playgroud)

数据网格的样式如下

<Style TargetType="{x:Type local:CustomDataGrid}">
        <Setter Property="BorderThickness"
                Value="1" />
        <!-- This is needed to force …
Run Code Online (Sandbox Code Playgroud)

wpf xaml datagrid

9
推荐指数
1
解决办法
191
查看次数

将双值导出为CSV

我试图将double值导出到CSV文件,如下所示

double[] arr = new double[] { 0.0000074, 0.00000123, 0.0000001254 };
using (StreamWriter writer = new StreamWriter(@"D:\Test.csv"))
{
    foreach (double item in arr)
    {
        writer.WriteLine(item);
    }
};
Run Code Online (Sandbox Code Playgroud)

CSV打开时的输出是Excel/Notepad相同的,如下所示

7.40E-06
1.23E-06
1.25E-07
Run Code Online (Sandbox Code Playgroud)

期望输出与CSV文件中的输入相同.期待任何形式的意见/建议.谢谢.

c# csv double export-to-csv

3
推荐指数
1
解决办法
1599
查看次数

标签 统计

c# ×1

csv ×1

datagrid ×1

double ×1

export-to-csv ×1

wpf ×1

xaml ×1