使用 属性 更改简单绑定到用户控件在 vs 扩展工具中不起作用 window

Simple binding to a user control using property change not works in vs extension tool window

我在 Vs 扩展中有一个 UserControl, 我想进行 属性 绑定,但由于某些原因它不起作用

xaml

<UserControl x:Class="RemoteDebuggerToolBarExtension.Windows.CommandRunnerControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0"
         xmlns:windows="clr-namespace:RemoteDebuggerToolBarExtension.Windows"
         Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
         Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300"
         d:DataContext="{d:DesignInstance windows:CommandRunnerControl}"
         Name="MyToolWindow">
<Grid>
    <StackPanel Orientation="Vertical">
        <TextBlock Margin="10" >Type your command here:</TextBlock>
        <TextBox Margin="10" Width="200" TextWrapping="WrapWithOverflow" Text="{Binding CommandData,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }"></TextBox>
        <Button Margin="10" Content="Run" Click="RunRemoteCommand"  Name="button1" />
    </StackPanel>
</Grid>

代码隐藏

 namespace RemoteDebuggerToolBarExtension.Windows

 public partial class CommandRunnerControl : UserControl, INotifyPropertyChanged
 {
    private string _commandData = string.Empty;

    public event PropertyChangedEventHandler PropertyChanged;

    public string CommandData
    {
        get => _commandData;
        set
        {
            _commandData = value;
            OnPropertyChanged(nameof(CommandData));
        }
    }

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

在里面输入文字时没有任何更新 我想念什么?

设置 DataContext 或明确指定绑定源:

<TextBox Margin="10" Width="200" TextWrapping="WrapWithOverflow"
         Text="{Binding CommandData,UpdateSourceTrigger=PropertyChanged, 
             RelativeSource={RelativeSource AncestorType=UserControl} }" />