這裏我有一個網格示例窗口。我需要在按下按鍵時捕捉事件。但是當我點擊網格區域然後按下按鍵時,它不會升高。它只有在Textbox集中的情況下才能工作。我知道它會工作,如果我從窗口捕獲它。但我有其他的應用程序用戶控件很少,我需要從不同的應用程序捕獲它。我試圖爲Window設置Focusable.false,併爲網格設置true,但它沒有幫助。 任何解決方案?KeyDown事件沒有從網格上升
<Window x:Class="Beta.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Closed="Window_Closed_1" Focusable="False">
<Grid KeyDown="Grid_KeyDown_1" Focusable="True">
<TextBox x:Name="tbCount" HorizontalAlignment="Left" Height="35" Margin="310,49,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="83"/>
</Grid>
這是更好,但在我的實際應用中它從每一個用戶控件雖然觸發keydown事件我把它只吸引到一個。我必須調查.. – Dork 2013-03-06 10:45:28
我有多個窗口,這不是正確的事情,使他們都集中 – Dork 2013-03-06 11:05:41