简体   繁体   中英

UserControl in a Window not working WPF

i'm trying to put a UserControl in a Window, for a strange reason it's not working. Even after rebuilding and cleaning the project.

<Window xmlns:Header="JWKBouwWPF.Controls.Header" x:Class="JWKBouwWPF.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:JWKBouwWPF"
    mc:Ignorable="d"
    Title="MainWindow" WindowState="Maximized">

This is my code, as it states it should be accesable by doing

在此处输入图片说明

在此处输入图片说明

I rebuild it a couple of times, deleted and re-added the UserControl, but to no avail.

Your namespace mapping is missing clr-namespace token. Replace xmlns:Header="JWKBouwWPF.Controls.Header" with xmlns:Header="clr-namespace:JWKBouwWPF.Controls.Header" .

See XAML Namespaces and Namespace Mapping for WPF XAML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM