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 8951823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:45:02+00:00 2026-06-15T13:45:02+00:00

I am pretty new with WPF and am doing some custom control stuff… My

  • 0

I am pretty new with WPF and am doing some custom control stuff…
My problem is that the code in one file is going to be way to much, so i want
to split the code in seperate files, so other people looking in that code aren´t going to be overwhelmed.

Okay to my question…
I got a ResourceDictionary… the “Generic.xaml”
In this file a got the template of an DataGrid:

    <Style TargetType="{x:Type local:BADataGrid}">
    <Style.Setters>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BADataGrid">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Background="{TemplateBinding Background}" 
                        Padding="{TemplateBinding Padding}" 
                        SnapsToDevicePixels="True">

           <!-- *SOME TEMPLATE CODE* -->

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="GridStyle" Value="CUSTOMER">
                            <Trigger.Setters>
                                <Setter Property="ColumnHeaderStyle">
                                    <Setter.Value>
                                        <Style TargetType="{x:Type DataGridColumnHeader}">
                                            <Setter Property="Background">
                                                <Setter.Value>
                                                    <ImageBrush>
                                                        <ImageBrush.ImageSource>
                                                            <Binding  Path="HeaderBackground" RelativeSource="{RelativeSource AncestorType=local:BADataGrid}">
                                                                <Binding.TargetNullValue>
                                                                    <ImageSource>
                                                                        headerBack.png
                                                                    </ImageSource>
                                                                </Binding.TargetNullValue>
                                                            </Binding>
                                                        </ImageBrush.ImageSource>
                                                    </ImageBrush>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Setter.Value>
                                </Setter>
                            </Trigger.Setters>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style.Setters>
</Style>

Now I want the “ControlTemplate.Triggers” part of the code above in another .XAML File.

Is this even possible?

  • 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-06-15T13:45:03+00:00Added an answer on June 15, 2026 at 1:45 pm

    Did it with a nasty workaround… I´ll just share it with you.

    I just implemented an event that is fired when the DataGrid is loaded.
    In this event I load the ResourceDictionarys i wanted to add to the control template
    in ResourceDictionary object´s. Then i iterate through all entrys in the ResourceDictionary object and add each seperate to the ControlTemplate´s resources…
    Here´s the code:

    void DataGridLoaded(object sender, RoutedEventArgs e)
        {
            BADataGrid dg = (BADataGrid)VisualTreeHelper.GetParent((DependencyObject)sender);
    
    
            List<string> resourceList = new List<string>();
            resourceList.Add(Properties.Resources.Customer);
    
            foreach (string s in resourceList)
            {
                System.Xml.XmlReader xmlReader = new System.Xml.XmlTextReader(new System.IO.StringReader(s));
                ResourceDictionary resource = (ResourceDictionary)XamlReader.Load(xmlReader);
    
                foreach (System.Collections.DictionaryEntry item in resource)
                {
                    dg.Resources.Add(item.Key, item.Value);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to WPF, and I'm trying to write a custom control that
I have a problem in wpf xaml and i'm pretty new on this so
I'm new to WPF so this is probably a pretty easy problem. I open
Couldn't find an answer to this one. I have a WPF ListView control that
I'm kinda new at both programming, and WPF. I know that this is pretty
I'm pretty new to WPF however i've got a solid understanding of WindowsForms. When
I'm pretty new to WPF and using the MVVM design pattern. To help learn
I'm still pretty new to ObjC. I noticed that it's pretty standard everywhere to
Still a bit new to the concept of M-V-VM in WPF, here's my problem:
I am pretty new to WPF and I cannot figure out how to update

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.