How to set Height of items in XAML so they always occupy the same proportion of available space in p
Posted
by aoven
on Stack Overflow
See other posts from Stack Overflow
or by aoven
Published on 2010-03-18T14:18:23Z
Indexed on
2010/03/18
14:21 UTC
Read the original article
Hit count: 388
I have an ItemsControl with the following ItemTemplate:
<DataTemplate x:Key="myItemTemplate">
<TextBlock Height="???" Text="{Binding Path=Description}" />
</DataTemplate>
My question is, how do I set the Height of the TextBlock in the template so that it automatically assumes ItemsControl.Height div ItemsCount
amount of vertical space?
When there's only one item, I'd like it to be the full height of container, when there're two, each should be half the size, and so on.
If possible, I'd prefer to do this completely in XAML to keep my ViewModel clean of UI logic.
© Stack Overflow or respective owner