tags:

views:

86

answers:

1

Hello! Help to understand. How to fill the panel from List. I want to get in the WrapPanel list of buttons and dynamically bind events to them. Thanks!

A: 

I'm not too sure if this is correct for what you are wanting to do, but it sounds very similar:

The XAML from the link above is as follows:

<ItemsControl x:Name="activitiesControl" Margin="10">
    <ItemsControl.Template>
        <ControlTemplate>
            <WrapPanel  Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" 
                    FlowDirection="LeftToRight" IsItemsHost="true">
            </WrapPanel>
        </ControlTemplate>
    </ItemsControl.Template>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Button Style="{DynamicResource ActionButton}" HorizontalAlignment="Right" Margin="5" 
                Content="{Binding Value}" Width="200" 
                Command="{Binding Path=ViewModel.ActionTypeCommand, 
                    RelativeSource={RelativeSource Mode=FindAncestor,     
                AncestorType=local:CustomerEditView}}" CommandParameter="{Binding Key}"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
Kyle Rozendo