有沒有辦法使用WPF Trigger
s將Focus
從一個控件設置爲另一個控件?WPF - 單擊按鈕時設置焦點 - 沒有代碼
像下面的例子:
<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之外進行。
我喜歡這個。我會嘗試一下。 – Vaccano 2010-02-06 20:02:35
這很好。雖然它使用代碼,但它並不是窗口後面的代碼,所以我可以確定。謝謝! – Vaccano 2010-02-06 23:50:36
這是我能夠使用DataTemplate並從ViewModel集中文本框的唯一工作解決方案。謝謝。 – alexandrudicu 2013-05-14 13:05:23