Control.InitializeFromXaml Method
Returns an element that is created by parsing the provided XAML, and sets that element to be the child of this control.
Assembly: System.Windows (in System.Windows.dll)
Parameters
- xaml
- Type: System.String
The input XAML, given as a string.
Return Value
Type: System.Windows.FrameworkElementThe object that is created and becomes the single child (implementation root) of this control.
You would typically use the return value of InitializeFromXaml to retain an instance value on which you would set any instance properties that the control class defines.
Although the xaml parameter type is String, you would seldom want to provide a literal string to fill this value. Instead, you might obtain this XAML content by loading a resource, either a Silverlight-specific resource, or a resource in the sense of an assembly part if you are defining a control's code and its visual appearance as component parts of an assembly. You might use other types such as Stream or StreamReader as intermediaries to load assembly resources.
If the root of the XAML parsing is not a FrameworkElement or subclass, InitializeFromXaml will throw an exception.