Я получаю это исключение: «Не удается разрешить TargetName userControl» при попытке установить DataContext.
Вот 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=mscorlib" 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>
код, который выдает исключение:
TagCheckView tagCheckView = new TagCheckView(); tagCheckView.DataContext = m.ViewModel; /* boom */
Спасибо за любые подсказки о том, что идет не так ...