开发者

"Cannot resolve TargetName" when setting 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜