Schlagwort: WPF

Adding Localization to .NET WPF Applications

Here I’d like to describe some approaches how .NET applications can be localized. General In general the texts that are supposed to be localized should be added to the Resources.resx file located under Properties of the project: The data is stores in an XML format, but also type save access properties are created automatically. Don’t…
Weiterlesen

Check if Code is Executed at Design Time

Sometimes it is important to prevent certain code being executed at design time. public static bool IsDesignTime { get { return (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime); } } In WPF applications the following code can be used instead: public static bool IsDesignTime { get { System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()); } }  

Showing a ComboBox with Installed Fonts

<ComboBox ItemsSource=“{Binding Source={x:Static Fonts.SystemFontFamilies}}“ SelectedItem=“{Binding SelectedFont, UpdateSourceTrigger=PropertyChanged}“ /> The ComboBox is bound to the System Fonts enumeration. The SelectedItem DependencyProperty is bound to a SelectedFont property of the ViewModel.

Use Text Wrapping in a WPF DataGrid TextColumn

You can simply use styles to enable text wrapping in a WPF DataGrid Column. This sets the element style of the standard column control and of the column control that is used when the cell is in edit mode. <DataGridTextColumn> <DataGridTextColumn.ElementStyle> <Style TargetType=“TextBlock“> <Setter Property=“TextWrapping“ Value=“WrapWithOverflow“/> <Setter Property=“TextTrimming“ Value=“WordEllipsis“/> </Style> </DataGridTextColumn.ElementStyle> <DataGridTextColumn.EditingElementStyle> <Style TargetType=“TextBox“> <Setter…
Weiterlesen