Reputation: 1771
Can we fill the rectangle by the given value?
<Rectangle Width="250" Height="50" Fill="White" Stroke="Black" StrokeThickness="4" RadiusX="20" RadiusY="20" />
If i give 50 mean the rectangle should be fill 50% yellow.(remaining 50% should be white ). If i give 20 mean the rectangle should be fill 20% yellow.(remaining 80% should be white ). Is it possible in windows phone 7?
Please let me know any idea for this. Please.
I have try to give the values from ViewModel. But i don't know how to give 50%, 20%, 75% color for the rectangle.
Upvotes: 0
Views: 98
Reputation: 15268
You should use a Grid control with 2 rows (or cells, depending on what orientation you want). Grids allow you to work with proportional heights and widths.
The rows Height properties are bound to you ViewModel.
Then you place a rectangle in the first grid row with the desired color.
Sample code:
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="{Binding Height1}"/>
<RowDefinition Height="{Binding Height2}"/>
</Grid.RowDefinitions>
<Rectangle Fill="Yellow" />
</Grid>
Upvotes: 1