你好。
可以采用ItemsControl的方式来实现:
<ItemsControl ItemsSource="{Binding}" x:Name="itemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5">
<ContentPresenter Content="{Binding}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
后台代码去绑定数据:
itemsControl.ItemsSource = "hello world";
根据需要去修改Margin的值就可以了。
希望我的答案能帮助更多的人。