C#C
C#2y ago
11 replies
Mek

✅ How to use a UserControl inside of a Window?

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="using:MeksIDE.ViewModels"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:uc="clr-namespace:MeksIDE.Views.MenuBar;assembly=MeksIDE"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="MeksIDE.Views.MainWindow"
        x:DataType="vm:MainWindowViewModel"
        Icon="/Assets/avalonia-logo.ico"
        Title="Edimuhtationer">

<Grid RowDefinitions="Auto, *">
    <DockPanel Grid.Row="0">
        <MenuItem DockPanel.Dock="Top">
            <!-- File -->
            <uc:FileMenu />
So I've moved part of the menu bar at the top of the screen to another UserControl file as my menu bar has a lot of options so I'm breaking it up. As the code above currently sits, I have a blank screen with an arrow in the top-right corner, but nothing else. I used the reference from this stack overflow comment to put in the xmlns:uc="" and the <uc:FileMenu />. Here is the full code for the <uc:FileMenu /> page that is in Views/MenuBar. I'm just not sure what I'm doing wrong. Thanks
Was this page helpful?