Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I "Click Through" a control in WPF?

I have an order entry form that has a ListBox with a list of line items. I have my items template, and one of the values is a ComboBox in each of my Items.

Now, my form can also create Credit memo's in addition to purchase orders, but when I am creating a credit memo, I want to put the words "Credit Memo" over the list box, however, the TextBlock covers the ComboBox in two of my line items. I would like to pass my click event through the TextBlock to the ComboBoxes but I'm not sure how to do it.

This is what I have, ( Maybe I am coming at this totally wrong, I am kinda a noob with 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> 
like image 913
Russ Avatar asked Jun 12 '09 18:06

Russ


People also ask

How can I access a control in WPF from another class or window?

Access of the controls from within the same assembly is hence allowed. If you want to access a control on a wpf form from another assembly you have to use the modifier attribute x:FieldModifier="public" or use the method proposed by Jean.

How do we refer to WPF controls in code?

Controls in WPF are accessed by their names (and the Name property). We specify the Name property in the XAML, and then can access the control by that name directly in C# code. This allows controls to interact. Example.

What are controls in WPF?

WPF SDK continues to use the term "control" to loosely mean any class that represents a visible object in an application, it is important to note that a class does not need to inherit from the Control class to have a visible presence.


1 Answers

<TextBlock IsHitTestVisible="False" .../> 
like image 57
Kent Boogaart Avatar answered Oct 30 '22 05:10

Kent Boogaart