8,735
社区成员
发帖
与我相关
我的任务
分享
<DataTemplate x:Key="MeetingInfoTemplate">
<Border Width="407" Height="351">
<Border.Background>
<ImageBrush ImageSource="Images/MeetingInfo.png" />
</Border.Background>
<Grid ShowGridLines="False">
<Grid.RowDefinitions>
<RowDefinition Height="52"></RowDefinition>
<RowDefinition Height="46"></RowDefinition>
<RowDefinition Height="180"></RowDefinition>
<RowDefinition Height="76"></RowDefinition>
</Grid.RowDefinitions>
<Label FontFamily="微软雅黑" FontSize="16" Grid.Row="0" Content=" 标题"/>
<Label FontFamily="微软雅黑" FontSize="16" Grid.Row="1" Content=" 内容:"/>
<Label Content="房间" FontFamily="微软雅黑" FontSize="16" Grid.Row="2"/>
<local:ImageButton Width="105" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="btnExit2" ImagePath="/Images/join_btn.png" Template="{StaticResource ImageButtonTemplate}" Grid.Row="3" />
</Grid>
</Border>
</DataTemplate>
cs文件如下:
UserControl tempctl = new UserControl();
tempctl.Margin = new Thickness(15, 15, 15, 15);
tempctl.Content = temp;
tempctl.ContentTemplate = (System.Windows.DataTemplate)FindResource("MeetingInfoTemplate");// 这里加载模板
tempctl.MouseLeftButtonUp += new MouseButtonEventHandler(scencectl_MouseLeftButtonUp);
tempctl.MouseDoubleClick += new MouseButtonEventHandler(scencectl_MouseDoubleClick);
m_scencectllist.Add(tempctl);
}
但现在scencectl_MouseDoubleClick事件是响应整个template的,即点即文字区域也响应,有什么方法只点击按钮才响应,[/quote]
在事件中 判断e.OriginalSource
<DataTemplate x:Key="MeetingInfoTemplate">
<Border Width="407" Height="351">
<Border.Background>
<ImageBrush ImageSource="Images/MeetingInfo.png" />
</Border.Background>
<Grid ShowGridLines="False">
<Grid.RowDefinitions>
<RowDefinition Height="52"></RowDefinition>
<RowDefinition Height="46"></RowDefinition>
<RowDefinition Height="180"></RowDefinition>
<RowDefinition Height="76"></RowDefinition>
</Grid.RowDefinitions>
<Label FontFamily="微软雅黑" FontSize="16" Grid.Row="0" Content=" 标题"/>
<Label FontFamily="微软雅黑" FontSize="16" Grid.Row="1" Content=" 内容:"/>
<Label Content="房间" FontFamily="微软雅黑" FontSize="16" Grid.Row="2"/>
<local:ImageButton Width="105" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="btnExit2" ImagePath="/Images/join_btn.png" Template="{StaticResource ImageButtonTemplate}" Grid.Row="3" />
</Grid>
</Border>
</DataTemplate>
cs文件如下:
UserControl tempctl = new UserControl();
tempctl.Margin = new Thickness(15, 15, 15, 15);
tempctl.Content = temp;
tempctl.ContentTemplate = (System.Windows.DataTemplate)FindResource("MeetingInfoTemplate");// 这里加载模板
tempctl.MouseLeftButtonUp += new MouseButtonEventHandler(scencectl_MouseLeftButtonUp);
tempctl.MouseDoubleClick += new MouseButtonEventHandler(scencectl_MouseDoubleClick);
m_scencectllist.Add(tempctl);
}
但现在scencectl_MouseDoubleClick事件是响应整个template的,即点即文字区域也响应,有什么方法只点击按钮才响应,