开发者

Fill a WrapPanel from a List

开发者 https://www.devze.com 2022-12-21 08:16 出处:网络
Is there any way of dynamically binding a list buttons to a WrapPanel as开发者_如何学运维 well as their events?I\'m not too sure if this is correct for what you are wanting to do, but it sounds very s

Is there any way of dynamically binding a list buttons to a WrapPanel as开发者_如何学运维 well as their events?


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

  • WPF - Fill a WrapPanel from a List

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号