我有一个带有ViewModel的MainWindow,当我按下一个按钮时,一个新的SubWindow,其onw ViewModel被打开,它接收“父”ViewModel,如下所示:
private AppViewModel vm;
public void Show(AppViewModel vm)
{
this.vm = vm;
this.DialogShown = true;
}
当我关闭SubWindow时,会调用此方法:
public void Hide()
{
vm.IsFocused = true;
this.DialogShown = false;
}
但是在我的MainWindow中,我的TextBox没有得到专注......
这是我的财产:
public bool IsFocused
{
get { return _isFocused; }
set
{
if (value != _isFocused)
{
_isFocused = value;
OnPropertyChanged("IsFocused");
}
}
}
这是我的xaml:
<TextBox Focusable="True" AcceptsReturn="True" ext:FocusExtension.IsFocused="{Binding IsFocused, Mode=TwoWay}" IsTabStop="False"/>
我做错了什么?