We have a requirement on custom control. The visual elements of the control template needs to be ldoded from the external xaml file(from the end user say CustomButton.xaml) based on the user request in order to support the Component UI customization. We ahve
followed the layered grid approach as explained below.
We have the custom control which has control tempalte contains 2 grids. In which the first grid(default grid) has the default visual elements. the second grid is empty(The visual elements are loaded dynamically). The triggers and converters are added into
control template based on the children of default grid visual element names.
Based on the user request the UI of the control template needs to be updated into the second grid from the external xaml file(c:\test.xaml) which has the necessary visual elements. These visual elements can have the same name which is already used in the
default grid children. For this we define a dependency property called IsCustomXAML. if this property set to true then we will do the necessary logic in the property change call back of IsCustomXAML. they are like below
1. load the visual elements from external xaml file(c:\test.xaml) into the second grid.
UIElement externalXAMLElement = (UIElement)XamlReader.Load(new XmlTextReader(control.XamlPath));
View Complete Post