Pergunta

I'm tyring to build a CheckBoxList to a Silverlight control I'm building and I'm having some trouble getting it right.

What I'm after, is a CheckBoxList that wraps the CheckBoxes vertically within a GridRow of * height. The problem I have is that I want to specify the height of the WrapPanel to be that of the row it is within.

In WPF it looks like the following:

<ScrollViewer BorderThickness="0"
              HorizontalScrollBarVisibility="Auto" 
              VerticalScrollBarVisibility="Hidden" >
    <ItemsControl Name="ic">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel Orientation="Vertical"
                                    Height="{Binding Path=ActualHeight,
                                            RelativeSource={RelativeSource Mode=FindAncestor, 
                                            AncestorType={x:Type ScrollContentPresenter}}}" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <CheckBox Content="{Binding Path=Description}" Margin="0,0,10,2" FontSize="12"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>

Silverlight doesn't support RelativeSource in the same way so I'm unable to do it in the same way I did with WPF. I've seen some work arounds for RelativeSource, but they're either massively verbous or I can't seem to get them working.

Surely there's a simple way of setting the height of the WrapPanel in Silverlight?

Foi útil?

Solução

In case anyone comes across this and doesn't already know, RelativeSource is being added in Silverlight 5

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top