David Bentley
David Bentley

Reputation: 864

C# WPF Control Library No accessible constructors

I have been working on creating a control resource library for a reusable dialog message box and have run into some issues. Below I have just the bar bones code behind and ViewModel

namespace MyLibrary
{
    public partial class WindowsMessage : UserControl
    {
        public WindowsMessage(Window parentWindow)
        {
            InitializeComponent();
            // Code behind stuff
        }
    }

    public class WindowsMessageViewModel : DialogBaseWindowViewModel
    {
        // ViewModel stuff
    }
}

I also have a ResourceDictionary that must be referenced by the using application that has the following:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:MyLibrary">

    <!-- Sets Datatype for control used as content in DialogBaseWindow. -->
    <DataTemplate DataType="{x:Type local:WindowsMessageViewModel}">
        <local:WindowsMessage/>
    </DataTemplate>

</ResourceDictionary>

This all works when the code is part of an application, but I get an error message that states:

"The type "WindowsMessage" does not include any accessible constructors."

Is there a way to get this working for Control Libraries?

Upvotes: 0

Views: 227

Answers (0)

Related Questions