Sirop4ik
Sirop4ik

Reputation: 5233

How to include a few User controls in window WPF?

I have created two user controls. As far as I understand in order to use your user control you need set(kind of import) here

<Window 
    ...
    xmlns:local ="clr-namespace:MeshCreator.UserControls.MyFirstUserControl"
    ...
   >

But according to this logic if I need to include my second user control I need set second line

<Window 
    ...
    xmlns:local ="clr-namespace:MeshCreator.UserControls.MyFirstUserControl"
    xmlns:local ="clr-namespace:MeshCreator.UserControls.MySecondUserControl"
    ...
   >

But this way I am getting an error

The attribute xmlns:local set more then one time

What am I doing wrong?

Upvotes: 0

Views: 45

Answers (1)

ASh
ASh

Reputation: 35646

"xmlns" means xml-namespace. if both UserControl are in "MeshCreator.UserControls" namespace, then add it once, and then add UserControl themselves:

<Window 
    ...
    xmlns:local ="clr-namespace:MeshCreator.UserControls"
    ...
   >
<Grid>
      <local:MyFirstUserControl Grid.Row="0"/>
      <local:MySecondUserControl Grid.Row="1"/>
</Grid>
</Window>

Upvotes: 3

Related Questions