讓我們從簡單的介紹開始。爲了更好地理解我的問題,我已經極大地簡化了這個例子。Touch vs Mouse,Silverlight
該項目是在Silverlight 4,我已經拿到了MainPage.xaml中,其中包括一個Button:
<Button x:Name="SelectedFillColor" Command="{Binding ChangeColorCommand}" Background="{Binding SelectedColor}">
<Button.Template>
<ControlTemplate>
<Ellipse Width="80" Height="80" Fill="{TemplateBinding Background}" Stroke="White" StrokeThickness="2"/>
</ControlTemplate>
</Button.Template>
</Button>
正如你可以看到我使用ChangeColorCommand命令來處理單擊/觸摸。在的MainPage的代碼隱藏我只是簡單綁定視圖模型到DataContext
this.DataContext = new MainPageViewModel();
的最後一步是我的ViewModel其中包括命令初始化方法,在構造函數中推出:
private void InitializeCommands()
{
this.ChangeColorCommand = new RelayCommand(() =>
{
this.SelectedColor = new SolidColorBrush(Colors.Yellow);
});
}
問題,
當我在平板電腦上運行此網頁時,我使用兩個設備:
鼠標,當我點擊橢圓按鈕,然後它將顏色更改爲黃色,
觸摸,當我選中橢圓按鈕然後它不會更改顏色,默認顏色存在。當我再次選中時,顏色會發生變化。爲什麼?
謝謝
按標籤我假設你的意思是點擊?我當然可以看到基於Tab鍵的不同行爲。 –
是的,是的,我只是在談論根據觸摸輸入點擊。 – Jarek