Design-time failure: WPF, Usercontrols and Namespaces

Posted by Simon Woods on Stack Overflow See other posts from Stack Overflow or by Simon Woods
Published on 2010-05-08T16:19:14Z Indexed on 2010/05/08 16:28 UTC
Read the original article Hit count: 429

Filed under:
|
|

Hi

I have a very simple WPF project comprising a Window and Usercontrol. I'm very much in a learning phase. It works fine when I run it. However, I am unable to see the form in design time. The problem, I believe is something to do with namespaces, but I don't understand where. It may well be a simple error

Main Window XML

<Window 
    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:views="clr-namespace:UserLogin"
    x:Class="UserLogin.MainView"
    x:Name="MainViewWindow"
    mc:Ignorable="d" 
    Title="Login" 
    Height="141" 
    Width="347"
    >

    <Grid>        
        <views:LoginView />
    </Grid>

</Window>

Main Window CodeBehind

Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports UserLogin

Namespace UserLogin

    Partial Public Class MainView
        Inherits System.Windows.Window

        Public Sub New()
            InitializeComponent()
        End Sub

    End Class

End Namespace

Usercontrol XAML

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             x:Class="UserLogin.LoginView"
             x:Name="LoginViewControl"
             mc:Ignorable="d" d:DesignHeight="96" d:DesignWidth="298">
    <Grid  Height="96" Width="298">
        <Button Command="{Binding OKCommand}" Height="21" Margin="0,0,90,16" Name="btnOK" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="76">OK</Button>
        <Button Command="{Binding CancelCommand}" Height="21" HorizontalAlignment="Right" Margin="0,0,9,16" Name="btnCancel" VerticalAlignment="Bottom" Width="75">Cancel</Button>
        <Label Height="23" HorizontalAlignment="Left" Margin="10,5,0,0" Name="Label1" VerticalAlignment="Top" Width="85">Name:</Label>
        <Label HorizontalAlignment="Left" Margin="10,32,0,0" Name="Label2" Width="85" Height="29" VerticalAlignment="Top">Password:</Label>
        <TextBox Margin="0,31,6,0" Name="txtPassword" Height="22" VerticalAlignment="Top" HorizontalAlignment="Right" Width="182" />
        <ComboBox Height="22" Margin="110,6,6,0" Name="cboNames" VerticalAlignment="Top" />
    </Grid>
</UserControl>

Usercontrol CodeBehind

Imports Microsoft.VisualBasic
Imports System
Imports UserLogin

Namespace UserLogin
    Partial Public Class LoginView
        Inherits System.Windows.Controls.UserControl

        Public Sub New()
            InitializeComponent()
        End Sub

    End Class
End Namespace

I think I'm missing something this namespace

xmlns:views="clr-namespace:UserLogin"

since intellisense doesn't give me the usercontrol declared within it in the XAML designer but rather reports the error "Unable to load the metadata for the assembly ... etc etc"

Thx for any suggestions

Simon

© Stack Overflow or respective owner

Related posts about wpf

Related posts about usercontrols