展示
<DataGrid x:Name="dataGrid" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding}" AutoGenerateColumns="false" SelectionUnit="CellOrRowHeader" SelectionMode="Single" IsReadOnly="True" HorizontalAlignment="Left" Margin="50,20,50,0">
<DataGrid.Columns>
<DataGridTextColumn Header="指标" Width="*" Binding="{Binding Path=name,Mode=OneWay}" FontSize="12" />
<DataGridTextColumn Header="数值" Width="3*" Binding="{Binding Path=value,Mode=OneWay}" FontSize="12" >
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Height" Value="auto"/>
<!--<Setter Property="Control.Foreground" Value="Green"/>-->
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
集合 赋值
ObservableCollection<SxAllData> sxallData = new ObservableCollection<SxAllData>() {
new SxAllData("心率及心率变异性" ,"平均"+Data.HAvg.ToString()+";最大值:"+Data.HMax.ToString() +";最小值"+Data.HMin.ToString()+";标准差"+Data.HStandardDeviation.ToString()+"。"+
" 心率变异性:SDNN:"+ Data.SDSD.ToString()+";RMS-SD:"+Data.RMS_SD.ToString()+" ;M-SD:"+Data.M_SD.ToString()+" ;SDSD:"+Data.SDSD.ToString()+" ;NN50:"+Data.NN50.ToString()+" ;PNN50:"+Data.PNN50.ToString()+" ;") ,
new SxAllData("皮肤电反应" ,"平均"+ Data.XAvg.ToString()+";最大值:"+ Data.XMax.ToString()+";最小值"+Data.XMin.ToString()+";标准差"+ Data.XStandardDeviation.ToString()+"。") ,
new SxAllData("血氧饱和度" ,"平均"+ Data.PAvg.ToString()+";最大值:"+ Data.PMax.ToString()+";最小值"+Data.PMin.ToString()+";标准差"+ Data.PStandardDeviation.ToString()+"。")
};
dataGrid.DataContext = sxallData;
赋值类
public class SxAllData
{
public String name { set; get; }
public String value { set; get; }
public SxAllData()
{
}public SxAllData(string name, string value)
{
this.name = name;
this.value = value;
}
}
显示
https://blog.youkuaiyun.com/qq_31494787/article/details/79582165
复制
https://www.cnblogs.com/santian/p/4366832.html
多行
https://zhidao.baidu.com/question/423911516.html
颜色
https://blog.51cto.com/weiyuqingcheng/2334676
行高
https://blog.youkuaiyun.com/yxys01/article/details/69525905
WPF DataGrid自定义样式
https://www.cnblogs.com/GeneralKING/archive/2012/11/20/2779486.html
maybe 行高。
<DataGrid>
<DataGrid.RowStyle>
<Style TargetType = "{x:Type DataGridRow}" >
< Setter Property="Height" Value="Auto"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
WPF DataGrid合并单元格
https://blog.youkuaiyun.com/youqingyike/article/details/47702463