将标签绑定到 ItemsControl

Binding Label to ItemsControl

我无法弄清楚如何将标签的内容绑定到 ItemsControl 对象的默认值 (ToString())。

ItemsControl 元素绑定到 stepList.ItemsSource = steps;

步骤对象是 private var steps = new ObservableCollection<Action>();

<ItemsControl Name="stepList" Margin="10,2,10,10">
<ItemsControl.ItemTemplate>
<DataTemplate>
    <Border Background="GhostWhite" BorderBrush="Gainsboro" BorderThickness="1" Margin="0,2,0,2" DockPanel.Dock="Top">
        <DockPanel Margin="0,2,0,2">
            <DockPanel Width="106" HorizontalAlignment="Right" DockPanel.Dock="Right">
                <Button DockPanel.Dock="Right" Click="_deleteStep" Width="22" Margin="0,0,10,0">
                    <Image Source="resources\icons\delete-bin.png" />
            </Button>
            <Button DockPanel.Dock="Right" Click="_editStep" Width="22" Margin="0,0,2,0">
                <Image Source="resources\icons\edit.png" />
            </Button>
            <Button DockPanel.Dock="Right" Click="_moveDown" Width="22" Margin="0,0,2,0">
                <Image Source="resources\icons\down.png" />
            </Button>
            <Button DockPanel.Dock="Right" Click="_moveUp" Width="22" Margin="0,0,2,0">
                    <Image Source="resources\icons\up.png" />
                </Button>
            </DockPanel>
            <DockPanel DockPanel.Dock="Left">
                <Label HorizontalAlignment="Stretch" Margin="10,0,0,0" Content="{????}"/>
            </DockPanel>
        </DockPanel>
    </Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

想通了!

Content="{Binding BindsDirectlyToSource=True}