2009-06-12 67 views
55

我有一個包含訂單項列表的ListBox的訂單輸入表單。我有我的項目模板,其中一個值是我的每個項目中的ComboBox如何「點擊」WPF中的控件?

現在,除了採購訂單外,我的表單還可以創建貸項憑證,但是當我創建貸項憑證時,我想將單詞「貸項憑證」放在列表框中,但是,TextBlock涵蓋了ComboBox在我的兩個訂單項中我想通過我的點擊事件通過TextBlockComboBox es,但我不知道如何去做。

這是我應得的(也許我在這個完全錯誤的到來,我還挺小白與WPF)

<ListBox SelectionMode="Single" Grid.Row="2" 
     ItemsSource="{Binding Path=LineItems}" HorizontalContentAlignment="Stretch" 
     IsSynchronizedWithCurrentItem="True" Background="#66FFFFFF"> 
    <ListBox.ItemContainerStyle> 
     <Style TargetType="{x:Type ListBoxItem}"> 
      <Setter Property="Background" Value="WhiteSmoke"/> 
      <Setter Property="BorderThickness" Value="1" /> 
      <Style.Triggers> 
       <DataTrigger Binding="{Binding Path=IsPartBackOrder}" Value="True"> 
        <Setter Property="Background" Value="Orange" /> 
       </DataTrigger>      
      </Style.Triggers> 
     </Style> 
    </ListBox.ItemContainerStyle> 
    <ListBox.ItemTemplate> 
     <DataTemplate DataType="{x:Type Entities:SalesOrderLineItem}" > 
      <OrderEntry:SalesOrderLineItemCreate DataContext="{Binding}" DeleteSalesOrderLineItem="DeleteSalesOrderLineItem" Margin="0,3,3,0" > 
       <OrderEntry:SalesOrderLineItemCreate.Resources> 
        <Style TargetType="{x:Type OrderEntry:SalesOrderLineItemCreate}"> 
         <Style.Triggers> 
          <DataTrigger 
            Binding="{Binding RelativeSource= 
             { 
             RelativeSource 
             Mode=FindAncestor, 
             AncestorType={x:Type ListBoxItem} 
             }, 
             Path=IsSelected 
            }" Value="True"> 
           <Setter Property="Background" Value="LightBlue" /> 
           <Setter Property="Foreground" Value="Black" /> 
          </DataTrigger> 
         </Style.Triggers> 
        </Style> 
       </OrderEntry:SalesOrderLineItemCreate.Resources> 
      </OrderEntry:SalesOrderLineItemCreate> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

<TextBlock Grid.Row="2" 
      Text="Credit Memo" 
      HorizontalAlignment="Center" 
      VerticalAlignment="Center" 
      FontSize="48" Height="Auto" 
      FontStyle="Italic" 
      Foreground="Red" 
      Opacity=".25"> 
    <TextBlock.Style> 
     <Style TargetType="{x:Type TextBlock}"> 
      <Style.Triggers> 
       <DataTrigger Binding="{Binding Path=OrderType}" Value="CR"> 
        <Setter Property="Visibility" Value="Visible" /> 
       </DataTrigger> 
       <DataTrigger Binding="{Binding Path=OrderType}" Value="CU"> 
        <Setter Property="Visibility" Value="Hidden" /> 
       </DataTrigger> 
      </Style.Triggers> 
     </Style> 
    </TextBlock.Style> 
</TextBlock> 

回答

117
<TextBlock IsHitTestVisible="False" .../> 
+0

有時候很簡單的事情。萬分感謝。 – Russ 2009-06-12 18:46:05