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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:20:13+00:00 2026-06-08T00:20:13+00:00

I have 5 borders inside a stackpanel and each border has a width as

  • 0

I have 5 borders inside a stackpanel and each border has a width as Window width/5. When I am maximizing the window then each border width should get resize according to window width/5.

I have tried with converter but it does’ not work as how converter will come to know window has resized.

<Window x:Class="ItemPanelTemplateTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel Orientation="Horizontal">
        <Border Height="20" Background="Red" Width="105" />
        <Border Height="20" Background="Green" Width="105" />
        <Border Height="20" Background="Yellow" Width="105" />
        <Border Height="20" Background="Blue" Width="105" />
        <Border Height="20" Background="Orange" Width="105" />
    </StackPanel>
</Window>

I don’t want to write anything on codebehind as I am using MVVM.

  • 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-08T00:20:15+00:00Added an answer on June 8, 2026 at 12:20 am

    Use different container than StackPanel. The best candidates here are Grid and UniformGrid, but since the latter requires less typing, here it is:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <UniformGrid Height="20" Rows="1">
            <Border Background="Red" />
            <Border Background="Green" />
            <Border Background="Yellow" />
            <Border Background="Blue" />
            <Border Background="Orange" />
        </UniformGrid>
    </Window>
    

    The grid will resize automatically with the window and then resize its contents uniformly.

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

Sidebar

Related Questions

I have a Grid inside a ScrollViewer inside a Border inside a StackPanel inside
I have a div inside another div. The outer div has rounded borders using
I have a div inside another div that has borders on the right and
I have two divs one inside another. I have given some border to both
I have an HTML table with collapsed and adjacent borders and a standard border
In my application resources I have: <Application.Resources> <Border x:Key=border1 BorderBrush={x:Null} BorderThickness=0 Height=159 Width=5 >
I have application where default Window's borders switched off Window tag definition looks like
I have a shape that is defined by an outer border and then an
I have a listbox inside of a stack panel inside of a border in
I have a window with a tree view control inside and a XML file.

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.