Q:

Resize control based on window width

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. 

A:

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.

