将标签绑定到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}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章