0

如何在 ItemTemplate 上使用 ItemsControl 上的 Items 是 UiElements 列表?

注意:我知道这不是预期用途,但它对调试很有用

<Window x:Class="WpfApplication4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow">
<ItemsControl>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>

    <Button Content="A" Name="TheButton"/>
    <CheckBox Content="AB" Name="TheCheckBox"/>
</ItemsControl>

4

0 回答 0