RainbowConsult.DK © 2020

Tilbage til forsiden










.NET serialization.



To serialize content to disk the most used formats are binary and XML. Below you can find Save and Load methods for both formats. In the examples below we serialize a "MyObject" to the specified filename.


Binary serialization.


You will need to reference System.Runtime.Serialization and System.Runtime.Serialization.Formatters.Binary







XML serialization.


You will need to reference System.Xml.Serialization










WPF Visual rendering.



Transformations in XAML can be either Layout transformations or render transformations.

Layout transforms are rendered at the layout pass of WPF whereas render transforms are rendered after the layout pass. Render transforms do not affect the layout of its parent container, layout transfoms do affect layout.


It is very important to understand the difference between the two render modes and when to use what.

In above example using the Layout transform will cause the scrollviewer to automatically adjust scroll extents depending on the new canvas size.



Using the render transform instead, simply resizes the canvas but does not affect its container and it becomes impossible to scroll to some portions of the canvas



Dependency properties in XAML.



XAML markup contains some very powerful features allowing you to connect one property directly to the value of another property.

Binding Text elements to other controls and their values, here we bind the slider value directly to the text box.




Here we bind the state of the checkbox directly to the enabled state of the combo.

With zero code we can turn the combo on or off depending on the state of the checkbox




Control manipulation in XAML.



Setting containerstyle properties on lists.


Certain properties within a ListBox is determined by the ItemContainerStyle rather than the ItemStyle itself. One such property is the margin of each item in a list.




Image Processing.



Creating, rotating and zooming an image.




Creating an BitmapSource from an area of the screen.


This example uses the GDI+ system from WinForms as this isn't supported in WPF. The final image is a WPF BitmapSource that can be assigned directly to the Source propertry of an WPF Image.