-
WPF Text Rendering Optimization (Text of WPF application is blurry or pixelated)
Situation You’re building a WPF application. Problem Some text is rendered blurry or pixelated. Solution Modify the text render options corresponding to your needs. Properties you can set on any UIElement: TextOptions.TextFormattingMode TextOptions.TextRenderingMode TextOptions.TextHintingMode A settings that has worked for me very well is TextOptions.TextFormattingMode=”Display”. These settings are inherited by all sub-elements so it’s okay…
-
Disable anti-aliasing in WPF
Situation You’re creating some kind of control that needs to be sharply visible. Problem WPF uses anti-aliasing on default so the control is rendered “soft”. Solution Deactivate anti-aliasing for the whole WPF application, the control or the specific part that needs to be sharp by setting the EdgeModeProperty to aliased. Sample /// <summary> /// Interaction…
-
“InitializeComponent() does not exist in the current context” after copying XAML files
Situation You copied XAML files in Visual Studio. Problem Visual Studio now can’t compile anymore, reporting that the InitializeComponent() method in the code-behind of your XAML files does not exist in the current context. Solution The build action of your XAML files has probably changed to “Resource”. Change it (back) to “Page”. Sources http://stackoverflow.com/questions/954861/why-can-visual-studio-not-find-my-wpf-initializecomponent-method
-
Localizing WPF controls with ResX files
Situation You want to localize a WPF control. Problem Books on WPF recommend to use Microsofts LocBaml.exe, which is actually just a sample that is, of course, not integrated anywhere. Solution Localize the WPF control using ResX files. create the ResX files set the scope of the ResX files to public add the Properties namespace…
-
Using a CLR-namespace of another assembly in XAML
Situation You want to use a CLR namespace of another assembly in your XAML. Problem A simple xmlns:custom=”clr-namespace:MyOtherAssembly.MyDesiredNamespace” won’t do the trick. Solution Identify the assembly within the namespace string. Example xmlns:custom=”clr-namespace:MyDesiredNamespace;assembly=MyOtherAssembly” Sources http://msdn.microsoft.com/en-us/library/ms747086.aspx
-
Setting the culture on WPF bindings
Situation You work on WPF bindings, for example a binding to a DateTime object. Problem The DateTime object is displayed in en-US culture format. Solution Set the current culture on the root element, which is most probably the outer most Grid element, of your XAML. For example: Set the culture in the corresponding ViewModel constructor…
-
WPF localization
Sources ResX: http://compositeextensions.codeplex.com/discussions/52910?ProjectName=compositeextensions MarkupExtension: http://www.wpftutorial.net/LocalizeMarkupExtension.html
-
The invocation of the constructor on type X that matches the specified binding constraints threw an exception
Situation You want to edit a WPF application using Visual Studio. Problem Visual Studio throws a XamlParseException that says ‘The invocation of the constructor on type X that matches the specified binding constraints threw an exception’. Solution Open the dialog [Debug] – [Exceptions] (CTRL+D, E) and check the ‘Thrown’ checkbox for ‘Common Language Runtime Exceptions’.…