1

Hi i am actually working on a WPF Library which provides a MainWindow with different basefunctionalities. The Integrator, wich uses the Component does actually Create this Window, to working with it must provide a CostomUserControl which inherits from "UcDatasourceBase". This Control will be placed in the middle of the mainwindow, but i do not know the effective Type of the CustomUserControl, only that it's implementing UcDatasouceBase.

Thats the way the CodeBehind of UcDatasourceBase looks like:

/// <summary>
/// Interaction logic for UcDatasourceBase.xaml
/// </summary>
public abstract partial class UcDatasourceBase : UserControl
{
    public IDatasource Datasource { get; private set; }

    public UcDatasourceBase(IDatasource datasource)
    {
        InitializeComponent();
    }
}

And how i Integrated the Control in XAML (this causes a Compiler error):

<Controls:UcDatasourceBase x:Name="_ucDatasourceBase" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="5,13,5,7" Grid.Row="2" />

In the Constructor of Mainwindow I finally want to set the Control by name:

    public MainWindow(UcDatasourceBase ucDatasourceBase)
    {
        _UcDatasourceBase = ucDatasouceBase;
        InitializeComponent();
    }

So how do i add Abstract Controls into xml without getting an Error?

Links i checked before:

Im Using .NET Framework 4.5 in Visual Studio 2012 Premium

EDIT:

The type "UcDatasourceBase" is abstract and must include an explicit value.

Community
  • 1
  • 1
LuckyLikey
  • 3,504
  • 1
  • 31
  • 54

1 Answers1

1

Create a new ContentControl in xaml, and set it:

<ContentControl x:Name="DataControl" />

Later in your code:

DataControl.Content = ucDatasourceBase;

Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78