How to embed a user control in a window #16125
-
Hi, Forgive me if this is a basic question, but I am having a tough time finding a straightforward answer. I have started a new project in Avalonia for desktop, and I am trying to use the MVVM approach. First, I have made several XAML user controls with their associated code-behinds and stored those in my Views folder. What I want to do is now lay those user controls out in my MainWindow.axaml view. Is it possible to do the following in my MainWindow view?
What I am trying to do here is define my overall main window as a grid, and have the element of a certain row-column be of the type 'SystemConfig' which is a user control that I have created. SystemConfig is itself using the Grid layout. Visual Studio is telling me that it's unable to resolve the type 'SystemConfig'. In my main window XAML I have this line Am I going about this wrong? Basically, I have created a bunch of separate views (XAML/code-behind files) and I want to display them all in a single window. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You need to use the XML namespace. Those types aren't automatically imported into the default XML namespace. eg. I prefer the "using" syntax for the xmlns: |
Beta Was this translation helpful? Give feedback.
You need to use the XML namespace. Those types aren't automatically imported into the default XML namespace. eg.
<views:SystemConfig Grid.Row="1" Grid.Column="0" />
I prefer the "using" syntax for the xmlns:
xmlns:views="using:Foo.Views"