I have the following XAML:
<sdk:Label Content="{Binding RefreshTextToggle, Converter={StaticResource enumToText}, ConverterParameter=ItemsOfInterest,FallbackValue='Please select items of interest to you'}"
Style="{StaticResource StandardLabel}"
Height="{Binding ElementName=ItemsOfInterest,Path=Height}"/>
<ListBox Name="ItemsOfInterest"
ItemsSource="{Binding Path=ItemsOfInterest}"
Margin="5"
MinHeight="25"
Width="250"
HorizontalAlignment="Left">
The height of the ItemsOfInterest is dynamic pending on how many elements are in it.
Anyone see what I am doing wrong with the height binding? It isn’t even close to the same size as the ItemsOfInterst.
You should bind to ActualHeight, which specifies the height it was arranged at. The Height property allows you to set a fixed height, but doesn’t tell you exactly how tall it is when arranged.
EDIT:
Actually, this is a known bug with Silverlight.
You would have to use the SizeChanged event like so:
With a code-behind of:
You could probably wrap this up into a nice attached behavior also.
EDIT:
Here is such a behavior:
With a code-behind of: