2010-09-28 131 views
1

我有一個從用戶控件派生具有以下XAML一個簡單的自定義控件:WPF自定義控件從用戶控件派生不響應鼠標點擊

<UserControl x:Class="EMS.Controls.Dictionary.MapTip" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:slData="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" 
     xmlns:infrv="clr-namespace:OCC600.Infrastructure.Interface.Views;assembly=EMS.OCC600.Infrastructure.Interface" 
     xmlns:igDP="http://infragistics.com/DataPresenter"  x:Name="root"     
     > 

    <UserControl.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="../Resources/Styles.xaml"/> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </UserControl.Resources> 
    <Viewbox x:Name="viewBox" > 
     <Border CornerRadius="10" Background="#80000000" BorderBrush="Black">     
      <Grid Name="contentGrid" Margin="0,20,0,0" >    
       <Grid.RowDefinitions>    
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="Auto"/>     
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="*"/>     
       </Grid.ColumnDefinitions>    

       <Border Grid.Row="2" Margin="5" Grid.ColumnSpan="2" Visibility="Visible" >             
        <igDP:XamDataGrid Margin="5"          
             Name="IdentifyDetailsDataGrid"  
             Style="{StaticResource readonlyGrid}" 
             ClipToBounds="False">       
         <igDP:XamDataGrid.FieldLayoutSettings> 
          <igDP:FieldLayoutSettings       
           AutoGenerateFields="True"                                 
           HighlightAlternateRecords="True"         
           FilterUIType="LabelIcons" 
           AllowAddNew="False" 
           AllowDelete="False"                 
           SelectionTypeCell="Single"         
           SelectionTypeField="Single"       
           /> 
         </igDP:XamDataGrid.FieldLayoutSettings> 
         <igDP:XamDataGrid.FieldSettings> 
          <igDP:FieldSettings 
           LabelClickAction="SortByOneFieldOnly"         
           AllowEdit="False" 
           AllowGroupBy="True"         
           CellClickAction="SelectRecord"        
           ExpandableFieldRecordHeaderDisplayMode="NeverDisplayHeader"/> 
         </igDP:XamDataGrid.FieldSettings> 
        </igDP:XamDataGrid>      
       </Border>   
     </Grid> 
     </Border> 
    </Viewbox> 
</UserControl> 

這個Maptip的一個實例添加到由JSMITH這裏提供的DragCanvas: http://www.codeproject.com/KB/WPF/DraggingElementsInCanvas.aspx

該控件動態提供了一個工具欄,其按鈕綁定到ViewModel中的命令。當我點擊按鈕時,沒有任何反應。但是,如果使用System.Windows.Primitives.Popup類替換Maptip的基類,則按鈕會響應鼠標單擊事件事件,並在此Maptip添加到拖動畫布時執行命令。

我在這裏看到的任何提示?

TIA。

回答