Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4078768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:42:57+00:00 2026-05-20T17:42:57+00:00

I have the following Style (defined as a Resource in xaml). This is basically

  • 0

I have the following “Style” (defined as a Resource in xaml). This is basically a “DataGridColumnHeaderStyle” with a Menu that implements Row filtering. It is assigned to the DataGrid using: ColumnHeaderStyle=”{StaticResource lclDataGridColumnHeaders}”

There are times in Code Behind I need to disable the (row filtering) Menu (menuColumnOptions), which is defined in this Style. Can anyone tell me how to access this element so I can change its Visibility via C#?

I tried: myDataGrid.Template.FindName(“menuColumnOptions”) but I received an error, something about it must be “applied”…

(I suppose the alternative solution is to create a duplicate “Style” WITHOUT this Menu and change all the Columns to use that style…)

<Style x:Key="lclDataGridColumnHeaders" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="{StaticResource appTextColor}"/>
<Setter Property="FontWeight" Value="DemiBold"/>
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Border x:Name="BackgroundBorder"
                        BorderThickness="0,1,0,1" 
                        Background="{StaticResource lclDataGridHeaderBackground}" 
                        BorderBrush="Transparent" 
                        Grid.ColumnSpan="2" />

                <ContentPresenter Margin="6,3,6,3" VerticalAlignment="Center" />

                <Path Grid.Column="1" x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" 
                        Width="8" Height="6" Fill="Gray" Stretch="Fill" Margin="0,0,8,0"
                        VerticalAlignment="Center" RenderTransformOrigin="0.5,0.4" />


                <Menu Grid.Column="3" x:Name="menuColumnOptions" VerticalAlignment="Center" Background="#FFF9F9F7" HorizontalAlignment="Right" >
                    <MenuItem Padding="0" SubmenuOpened="MenuItemColumnOptions_SubmenuOpened">
                        <MenuItem.Header>
                            <Border BorderBrush="{StaticResource appTextColor}" BorderThickness="1" CornerRadius="2" Height="20" Width="20" >
                                <Path Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Fill="{StaticResource appTextColor}"
                                        Width="10" Height="8" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.4" Margin="2,0"/>
                            </Border>
                        </MenuItem.Header>
                        <MenuItem x:Name="clearFilterMenuItem" Header="Clear Filter..." Click="ClearFilter_Click" IsEnabled="False">
                            <MenuItem.Icon>
                                <Image Source="/IngramBook.WpfTableEditor;component/Images/edit_undohs.png" Width="16" Height="16"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator />
                        <MenuItem Header="Equals..." Click="CustomAutoFilter_Click" />
                        <MenuItem Header="Does Not Equal..." Click="CustomAutoFilter_Click"/>
                        <Separator />
                        <MenuItem Header="Begins With..." Click="CustomAutoFilter_Click"/>
                        <MenuItem Header="Ends With..." Click="CustomAutoFilter_Click"/>
                        <Separator />
                        <MenuItem Header="Contains..." Click="CustomAutoFilter_Click" />
                        <MenuItem Header="Does Not Contain..." Click="CustomAutoFilter_Click"/>
                        <Separator />
                        <MenuItem Header="Custom Filter..." Click="CustomAutoFilter_Click">
                            <MenuItem.Icon>
                                <Image Source="/IngramBook.WpfTableEditor;component/Images/Filter2HS.png" Width="16" Height="16"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator />
                        <MenuItem Header="Select Individual Values..." Click="SelectIndividualItems_Click">
                            <MenuItem.Icon>
                                <Image Source="/IngramBook.WpfTableEditor;component/Images/checkboxhs.png" Width="16" Height="16"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator />
                        <MenuItem Header="Trim Trailing White Spaces..." Click="TrimTrailingWhiteSpaces_Click"/>
                        <MenuItem Header="Capitalization" >
                            <MenuItem.Icon>
                                <Image Source="/IngramBook.WpfTableEditor;component/Images/FontHS.png" Width="16" Height="16"/>
                            </MenuItem.Icon>
                            <MenuItem Header="Capitalize Each Word" Click="CapitalizeEachWord_Click"/>
                            <MenuItem Header="UPPERCASE" Click="Uppercase_Click"/>
                            <MenuItem Header="lowercase" Click="Lowercase_Click"/>
                        </MenuItem>
                        <Separator />
                        <MenuItem Header="Hide Column" Click="HideColumn_Click"/>
                        <Separator />
                        <MenuItem x:Name="deleteColumnMenuItem" Header="Delete Column" Click="dropColumnButton_Click">
                            <MenuItem.Icon>
                                <Image Source="/IngramBook.WpfTableEditor;component/Images/DeleteHS.png" Width="16" Height="16"/>
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                </Menu>

                <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
                <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="SortDirection" Value="Ascending">
                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                    <Setter TargetName="SortArrow" Property="RenderTransform">
                        <Setter.Value>
                            <RotateTransform Angle="180" />
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="SortDirection" Value="Descending">
                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                </Trigger>
                <Trigger Property="SortDirection" Value="{x:Null}">
                    <Setter TargetName="SortArrow" Property="Visibility" Value="Collapsed" />
                </Trigger>
                <Trigger Property="DisplayIndex" Value="0">
                    <Setter Property="Visibility" Value="Collapsed" TargetName="PART_LeftHeaderGripper" />
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True" >
                    <Setter Property="Background" TargetName="BackgroundBorder" Value="{StaticResource appButtonBackgroundHighlight}" />
                    <Setter Property="BorderBrush" TargetName="BackgroundBorder" Value="Transparent" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Setter.Value>
</Setter>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:42:58+00:00Added an answer on May 20, 2026 at 5:42 pm

    Here is what I ended up doing.

    I copied the Style and removed the Menu from this Copy.

    Then, in code I just set it using:

    myDataGrid.ColumnHeaderStyle = (Style)FindResource(“lclDataGridLockedColumnHeaders”);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following style defined in my App.xaml <Style x:Key=textBoxMultiline TargetType={x:Type TextBox} >
I have the following custom defined Button defined in my App.xaml file. <Style x:Key=DispatchListCallButton
I have the following XAML: <TextBlock Text={Binding ElementName=EditListBox, Path=SelectedItems.Count} Margin=0,0,5,0/> <TextBlock Text=items selected> <TextBlock.Style>
In <Window.Resources> I have defined following style: <Style x:Key=textBlockStyle TargetType=TextBlock> <Setter Property=Margin Value=5,0,5,0/> </Style>
I have the following XAML defined. <Popup x:Class=EMS.Controls.Dictionary.MapTip xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml PopupAnimation=Slide AllowsTransparency=True Placement=Mouse x:Name=root
I have the following style defined in the ResourceDictionary of a Silverlight 4.0 application
I have the following style defined... <!-- Blue Button --> <Style x:Key=BlueButton TargetType={x:Type Button}>
I have the following window, which displays a listview. I defined a style for
In my application, I have defined the following style for TextBlocks. <Style TargetType={x:Type TextBlock}>
My situation is like following. I have a App.xaml which includes Style for ListView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.