【发布时间】:2019-08-20 03:13:50
【问题描述】:
有没有办法使用 WPF Triggers 将 Focus 从一个控件设置到另一个控件?
像下面的例子:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Name="txtName"></TextBox>
<TextBox Grid.Row="1" Name="txtAddress"></TextBox>
<Button Grid.Row="2" Content="Finish">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<!-- Insert cool code here-->
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</Page>
有没有办法让这个EventTrigger 专注于文本框“txtName”?
我正在尝试找到使用严格 MVVM 执行此类操作的方法。如果这是不应该通过 XAML(在 MVVM 中)完成的事情,那很好。但我希望看到一些关于它如何适应 MVVM 模式的文档,在 XAML 之外执行它。
【问题讨论】:
标签: c# wpf mvvm focus eventtrigger