Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The property "DataContext" does not exist in the "http://schemas.microsoft.com/expression/blend/2008" namespace

I'm using a DesignTime DataContext inside of my WPF Styles to get full IntelliSense support.

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:alarm="clr-namespace:Foo.Alarm;assembly=HtCore"
    mc:Ignorable="d">

    <Style TargetType="TreeViewItem" d:DataContext="{d:DesignInstance alarm:HtAlarmBase}">

    </Style>

</ResourceDictionary>

But the Designer highlights it and says:

The property "DataContext" does not exist in the "http://schemas.microsoft.com/expression/blend/2008" namespace

error

Is there a solution to hide this "error message"?

like image 492
Dominic Jonas Avatar asked Mar 26 '18 07:03

Dominic Jonas


1 Answers

You could try:

<Style TargetType="TreeViewItem">
    <d:Style.DataContext>
        <x:Type Type="alarm:HtAlarmBase" />
    </d:Style.DataContext>
</Style>

I don't really follow where you're headed with this though.

I would usually provide a design time datacontext for a whole view, including data for the treeview items. Without that, I wouldn't have any treeview items at all to show in the designer.

like image 85
Andy Avatar answered Jan 01 '23 07:01

Andy