开发者

"Cannot resolve TargetName" when setting DataContext

开发者 https://www.devze.com 2023-04-03 07:49 出处:网络
I am getting this exception: \"Cannot resolve TargetName userControl\" when I try to set the DataContext.

I am getting this exception:

"Cannot resolve TargetName userControl"

when I try to set the DataContext.

Here's the xaml:

<UserControl x:Class="TagCheckView"
         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:System="clr-namespace:System;assembly=mscorli开发者_开发知识库b" 
         mc:Ignorable="d" Margin="3,0">
    <Grid x:Name="LayoutRoot" >
    <VisualStateManager.VisualStateGroups>
        <!-- snip -->
    </VisualStateManager.VisualStateGroups>
    <TextBlock Text="{Binding Tag.Name, Mode=TwoWay, TargetNullValue='Value is Null'}" 
               TextWrapping="Wrap" Foreground="Red"  />
    </Grid>
</UserControl>

And the code that throws the exception:

 TagCheckView tagCheckView = new TagCheckView();
 tagCheckView.DataContext = m.ViewModel;  /* boom */

Thanks for any hints on what's going wrong...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号