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

  • Home
  • SEARCH
  • 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 167063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:12:29+00:00 2026-05-11T12:12:29+00:00

When I create WPF applications, very quickly my XAML starts to bloat. I then

  • 0

When I create WPF applications, very quickly my XAML starts to bloat.

I then approach the XAML/style issue in a HTML/CSS way, looking for repetitive code and packing it into styles which I put into my Window.Resources section.

Is this the way others are doing it or is there some better way now in XAML? It just seems that the two blocks below only differ on two little words, it seems that I could put it in some kind of functional user control (this is a left-side menu) so that when I have 25 elements in my menu I could just have 25 lines of same with the names and perhaps the Click targets.

Or perhaps when I move this to MVVM this issue will take care of itself with DataBinding (it is currrently just a hard-coded prototype), so I can keep the names of the menu items in a collection in my ViewModel and it then creates the menu dynamically in an ItemsControl?

Or are bloated XAML files just a fact of life with WPF applications?

What kind of XAML styling strategies do you have when you create WPF applications?

Window.Resources (top of file):

<Window.Resources>     <Style x:Key='Link' TargetType='Button'>         <Setter Property='Cursor' Value='Hand'/>         <Setter Property='Foreground' Value='#555'/>         <Setter Property='Background' Value='Transparent'/>         <Setter Property='Template'>             <Setter.Value>                 <ControlTemplate TargetType='Button'>                     <TextBlock TextDecorations='Underline'                  Text='{TemplateBinding Content}'                 Background='{TemplateBinding Background}'/>                     <ControlTemplate.Triggers>                         <Trigger Property='IsPressed' Value='True'>                             <Setter Property='Foreground' Value='Red'/>                         </Trigger>                     </ControlTemplate.Triggers>                 </ControlTemplate>             </Setter.Value>         </Setter>     </Style> </Window.Resources> 

Current XAML:

<Expander HorizontalAlignment='Left' Header='File' VerticalAlignment='Top' ExpandDirection='Down' Width='200' Padding='2'>     <Expander.Background>         <LinearGradientBrush>             <GradientStop Color='#bbb' Offset='0'/>             <GradientStop Color='#ccc' Offset='1'/>         </LinearGradientBrush>     </Expander.Background>     <Border CornerRadius='5'>         <Border.Background>             <LinearGradientBrush>                 <GradientStop Color='#ccc' Offset='0'/>                 <GradientStop Color='#bbb' Offset='1'/>             </LinearGradientBrush>         </Border.Background>         <StackPanel HorizontalAlignment='Stretch' VerticalAlignment='Top'>             <Button Click='buttonClose_Click'                  Style='{StaticResource Link}'                  Margin='10 3 3 3'                 Content='Close'>             </Button>         </StackPanel>     </Border> </Expander>  <Expander HorizontalAlignment='Left' Header='Customers' VerticalAlignment='Top' ExpandDirection='Down' Width='200' Padding='2'>     <Expander.Background>         <LinearGradientBrush>             <GradientStop Color='#bbb' Offset='0'/>             <GradientStop Color='#ccc' Offset='1'/>         </LinearGradientBrush>     </Expander.Background>     <Border CornerRadius='5'>         <Border.Background>             <LinearGradientBrush>                 <GradientStop Color='#ccc' Offset='0'/>                 <GradientStop Color='#bbb' Offset='1'/>             </LinearGradientBrush>         </Border.Background>         <StackPanel HorizontalAlignment='Left' VerticalAlignment='Top'>             <Button Click='btnAppPage_Click'                  Tag='CustomerAdd'                 Style='{StaticResource Link}'                  Margin='10 3 3 3'                 Content='Create Customer'/>         </StackPanel>     </Border> </Expander> 
  • 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. 2026-05-11T12:12:30+00:00Added an answer on May 11, 2026 at 12:12 pm

    Simple: identify repetition and move it into a control. The control can have whatever properties necessary to compose the required variations at runtime. And it can be re-templated by virtue of being a control.

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

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer It works straight forward with a simple cast. Dictionary<String, Int32>… May 11, 2026 at 1:34 pm
  • added an answer SELECT ... FROM .... LEFT JOIN ( a INNER JOIN… May 11, 2026 at 1:34 pm
  • added an answer Use the adr microformat: http://microformats.org/wiki/adr If you also want to… May 11, 2026 at 1:34 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.