我在Silverlight應用程序中有一個Datagrid。用戶可以使用Tab鍵將焦點放在Datagrid上,並使用向上和向下箭頭鍵在各行之間移動。在Silverlight應用程序中使用空格鍵選擇Datagrid行
請教,如何在用戶點擊選定行的空格鍵時觸發行選擇事件。
下面的代碼片段:
<Custom:ClientControl
x:Class="TestNamespace.Modules.Views.SampleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
<sdk:DataGrid x:Name="dg" ...>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding DoSomething}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<sdk:DataGrid.Columns>
...
感謝瑞恩的幫助。 但是,我在XAML文件中添加上面的行後看到錯誤「成員」InputBindings「無法識別或無法訪問」。我已經添加了代碼片段以供參考。 – AaBa
您能否顯示您聲明'skd'的地方,謝謝 –
我已經更新了代碼段。 – AaBa