Pieter Schreurs
Pieter Schreurs

Reputation: 51

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

enter image description here

enter image description here

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

Upvotes: 1

Views: 244

Answers (1)

V.Leon
V.Leon

Reputation: 586

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

Upvotes: 2

Related Questions