Reputation: 2855
I know how to create a simple XAML interface for a page, but I spend a lot of my time copying and pasting code since I have no idea how to create reusable XAML in a proper way, I know about styles but they don't quite fill the role. What I would prefer to do is to call them in the following way:
<CustomElement attribute1="bla" attribute2="{Binding somethingElse}"/>
Just like all the other GUI objects in the Silverlight framework. Any help or hint would be useful.
Upvotes: 1
Views: 165
Reputation: 27085
Basically there are two options. Both solutions act like any other Silverlight control. They can be inserted at random places in pages like you would normally insert a Button
or a StackPanel
. The option of choice depends on the specific reuse scenario.
UserControl
. These define their own XAML layout and are very easy to create. Consider looking at ScottGu's tutorial. For a (much) better understanding, please look at this page comparing the features of UserControl
s and custom controls more in-depth.
Upvotes: 2