Binding Converter and multibinding

I want to create 4 rectangles stacked to one row.

|----|--|------|------------|

The width of every rectangle is binded to value in %.

I decided to group rectangles to horizontal StackPanel. To calculate the width of the rectangle I want to write convertor.

What I don't know is how to create converter that must be binded to: - value in % I want to pass the width of parent to converter parameter.

How to write parameter to bind it to parent's width?

Thank you for your answers.

Answers


Get rid of the StackPanel and put a Grid with one row and 4 column, That will do the trick. You can resize the control and it will behave properly. Bellow code the ColumnDefinition Width is actually a Percentage value. for example the first rectangle bellow takes 20% of the total width because the ColumnDefinition set 0.2* on that column.

   <Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.2*"/>
        <ColumnDefinition Width="0.1*"/>
        <ColumnDefinition Width="0.25*"/>
        <ColumnDefinition Width="0.45*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition /> 
    </Grid.RowDefinitions>

    <Rectangle Grid.Column="0" Fill="Black" Stroke="White" StrokeThickness="1"/>
    <Rectangle Grid.Column="1" Fill="Black" Stroke="White" StrokeThickness="1"/>
    <Rectangle Grid.Column="2" Fill="Black" Stroke="White" StrokeThickness="1"/>
    <Rectangle Grid.Column="3" Fill="Black" Stroke="White" StrokeThickness="1"/>
</Grid>

Need Your Help

dc.js: stacked area chart using reduceCount method

javascript mapreduce dc.js crossfilter

I'm fairly new to the dc.js/crossfilter/d3 trifecta, and have a question about grouping variables for building a stacked area chart. I've been following tutorials like this one that show how to gen...

How to create a popup box where users can copy text?

javascript jquery html popup

In my HTML page I generate a link, where users can grab to use for things. I need to somehow give the user the link where they can see the link and then copy the link to clip board.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.