silverlightxamlbindingsilverlight-4.0actualheight

Binding position to ActualHeight


I want to bind a lists position to its own height in XAML. So its lower left corner always will be at 0.0 of the canvas. I'm using elementBinding to get the ActualHeight and a converter to invert the property. But the height sent to the converter is 0.

How do I solve this or am I going at this the wrong way?

<Canvas x:Name="DisplaySurface">
    <ListBox x:Name="MenuList" Visibility="Visible"  
             Canvas.Top="{Binding ElementName=MenuList, Path=ActualHeight, 
             Converter={StaticResource LamdaConv}, ConverterParameter='val=>-val'}">

         <ListBoxItem Content="item 1" />
         <ListBoxItem Content="item 2" />
         <ListBoxItem Content="item 3" />
         <ListBoxItem Content="item 4" />
         <ListBoxItem Content="item 5" />
         <ListBoxItem Content="item 6" />
     </ListBox>
</Canvas>

Solution

  • Try the binding {Binding ActualHeight, RelativeSource={RelativeSource Self},Converter={StaticResource LamdaConv}, ConverterParameter='val=>-val'}