0
我有Popup
窗口,其中動態附加UserControl
。在這裏我需要設置第一個控件的焦點。如果我使用:焦點管理器問題wpf
FocusManager.FocusedElement="{Binding ElementName=txtcode}"
on UserControl
遊標未到來。任何人都可以幫助我將重點放在UserControl
的第一個元素上。
在此先感謝。
我有Popup
窗口,其中動態附加UserControl
。在這裏我需要設置第一個控件的焦點。如果我使用:焦點管理器問題wpf
FocusManager.FocusedElement="{Binding ElementName=txtcode}"
on UserControl
遊標未到來。任何人都可以幫助我將重點放在UserControl
的第一個元素上。
在此先感謝。
我剛剛需要做到這一點,但不是在用戶控制,所以可能沒有幫助。什麼我需要做的就是添加的FocusManager位在Window標籤:
<Window x:Class="xxxxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" FocusManager.FocusedElement="{Binding ElementName=txtcode}">
並確保我正確地命名控制:
<TextBox Name="txtcode" Text="" />
雖然我是新來WPF和避風港尚未與用戶控件一起工作。
嘗試使用觸發器來代替http://stackoverflow.com/questions/2204063/wpf-set-focus-when-a-button-is-clicked-no-code-behind – 2013-03-21 19:21:57