For the past few days I've been trying to wrap my head around the following layout of TextBlocks:
-------------------- -----------
| 1 | | |
-------------------- | 3 |
| 2 | | |
----------------- -----------
All of the TextBlocks have dynamic width. They have fixed height and are in a fixed-size container. They need to meet the following requirements:
- 2 has maximum priority - it needs to always be at full length.
- 3 can fill the remaining space left after sizing 2.
When ignoring TextBlock 1, these two requirements could be fulfilled by putting the two other TextBlocks in a Grid, with columns set to "auto" and "*" respectively.
There is a third requirement though:
- 1 assumes all the space it can, but without restricting 3.
Examples:
Long content in block 3 (block 2 content is full length, block 3 content gets trimmed):
----------------- -------------
| 1 | | |
----------------- | 3 |
| 2 | | |
----------------- -------------
Short content in block 3 (both block 2 and 3 content are full length; block 1 fills the remaining space):
--------------------- ---------
| 1 | | |
--------------------- | 3 |
| 2 | | |
----------------- ---------
Is there a way to achieve this layout in WPF? How?
I don't think this is possible with pure XAML. One way to accomplish your requirements is implementing your own panel that does all the magic. Here is one implementation:
Usage: