基本上我有一個表面工具包ScatterView綁定到模板化爲ImageView的圖像路徑列表。 ImageView控件使用MouseUp事件,但該事件不會在鼠標上觸發。我也嘗試過PreviewMouseUp,沒有運氣。爲了澄清,我正在使用Surface ToolKit構建一個Win7觸摸應用程序。如何避免ScatterViewItem捕獲鼠標事件?
Window.xaml:
<s:SurfaceWindow x:Class="SurfaceApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:view="clr-namespace:SurfaceApplication1"
Title="SurfaceApplication1"
>
<Grid>
<s:ScatterView x:Name="scatterView">
<s:ScatterView.ItemTemplate>
<DataTemplate>
<view:ImageView DataContext="{Binding}" MinHeight="300" MinWidth="300"/>
</DataTemplate>
</s:ScatterView.ItemTemplate>
</s:ScatterView>
</Grid>
Window.xaml.cs:
public Window1()
{
InitializeComponent();
Loaded += new RoutedEventHandler(SurfaceWindow1_Loaded);
}
void SurfaceWindow1_Loaded(object sender, RoutedEventArgs e)
{
scatterView.ItemsSource = Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures", "*.jpg");
}
ImageView.xaml:
<UserControl x:Class="SurfaceApplication1.ImageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" PreviewMouseUp="Grid_MouseUp">
<Grid MouseUp="Grid_MouseUp">
<StackPanel>
<Image Source="{Binding}"/>
<TextBlock Text="{Binding}" Height="20" Width="100"/>
</StackPanel>
</Grid>
有沒有人知道解決這個問題的方法?我需要在ImageView中處理MouseUp事件。謝謝。
不幸的是,這也不起作用。 – evanb 2011-04-20 23:57:44