C#: Divide XAML-Page in different parts
In Java you can create different JPanel-classes for example and put them on a frame.
I want to do sth. like this in C# too.
I have a XAML-Page with two equal parts. I want to put the part in a different "element" and include them tow times in the xaml-page.
Its possible to do that?开发者_开发问答
You can create the usercontrol in XAML and that user control you can place in your pagecontainer on your page.
Plaese visit this. might it can help you.
http://www.codeproject.com/KB/WPF/UserControl.aspx
You must in fact put the different controls of your application in different userControls (Add New =>Silverlight UserControl in Visual Studio)
an classic UserControl XAML File looks like that:
<UserControl xmlns="..." xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:class="MyApp.MyControl" >
[...]
</UserControl>
VS will generate the MyApp.MyControl class for you.
Then, in another UserControl, you can use the MyControl UserControl:
<UserControl xmlns="..." xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyApp" x:class="MyApp.MyMainControl" >
[...]
<local:MyControl />
[...]
</UserControl>
here the local xml namespace points to the MyApp .NET namespace in the same assembly. In fact, any control used in a xaml file (for instance an user control) is simply a class.
精彩评论