繁体   English   中英

如何更新ListBox项目中的控件

[英]How to update control inside ListBox item

我有一个ListBox定义如下。 我在ListView项目中有CheckBox需要以编程方式检查/取消选中(只是想实现选择/取消选择所有操作)。 实现这一目标的最佳方法是什么?

<ListBox Margin="0,0,10,0" Name="listViewChanges" SelectionMode="Multiple">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <CheckBox x:Name="lblChangedSelected" IsChecked="{Binding Selected}" VerticalAlignment="Center" VerticalContentAlignment="Center" Margin="10,0,0,0"></CheckBox>
                <Label x:Name="lblChangedStatus" Content="{Binding Status}" VerticalContentAlignment="Center"></Label>
                <Label x:Name="lblChangedPath" Content="{Binding Path}" VerticalContentAlignment="Center"></Label>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

你应该拥有绑定工具INotifyPropertyChanged背后的类。 然后,当您更改属性时,触发NotifyPropertyChanged事件,绑定应自动更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM