本文介绍了如何在DataGridTextColumn中将XAML中的双值格式化为德文格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有这个简单的代码,我想知道如何将它转换成德语格式(#。###,##)? //显示#。## < DataGridTextColumn Header =Sum ValueBinding ={Binding SumValue}/> 解决方案在这种情况下,请尝试几个选项:添加启动事件 App.xaml ,它建立了必要的语言文化。它影响日期的显示,双重值,金额等。 XAML <应用程序x:Class =DataGridTargetUpdateHelp.App xmlns =http://schemas.microsoft.com / winfx / 2006 / xaml / presentation xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml StartupUri =MainWindow.xaml启动= Application_Startup > < Application.Resources> < /Application.Resources> < / Application> 代码隐藏 public partial class App:Application { private void Application_Startup(object sender,StartupEventArgs e) { FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage(de-DE))); // CultureInfo.CurrentCulture.IetfLanguageTag返回当前的语言代码} } B。使用 DataGridTemplateColumn 在这种情况下,您可以设置任何 Control 在DataGridCell中显示值: < DataGrid.Columns> < DataGridTemplateColumn Header =ID> < DataGridTemplateColumn.CellTemplate> < DataTemplate> < TextBlock Text ={Binding Path = ID,StringFormat = {} {0:N2}}xml:lang =de-DE/> < / DataTemplate> < /DataGridTemplateColumn.CellTemplate> < / DataGridTemplateColumn> < /DataGrid.Columns> I have this simple piece of code and I am wondering how to convert it to German format (#.###,##) ?// displays #.##<DataGridTextColumn Header="Sum Value" Binding="{Binding SumValue}"/> 解决方案 In this case try several options:Add Startup event for App.xaml, which establishes the necessary language culture. It affects the display of the date, double values, sums of money, etc:XAML<Application x:Class="DataGridTargetUpdateHelp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" Startup="Application_Startup"> <Application.Resources> </Application.Resources></Application>Code-behindpublic partial class App : Application{ private void Application_Startup(object sender, StartupEventArgs e) { FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(System.Windows.Markup.XmlLanguage.GetLanguage("de-DE"))); // CultureInfo.CurrentCulture.IetfLanguageTag return the current code of language }}In this case you can set any Control to display values in the DataGridCell:<DataGrid.Columns> <DataGridTemplateColumn Header="ID"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=ID, StringFormat={}{0:N2}}" xml:lang="de-DE" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn></DataGrid.Columns> 这篇关于如何在DataGridTextColumn中将XAML中的双值格式化为德文格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 08:47