wpf数据双重绑定后,MVVM绑定控件失效

wpf数据双重绑定后,MVVM绑定控件失效
代码如下

UI是ListBox循环嵌套(此处只保留了核心控件)

<ListBox x:Name="lbOrder" ItemsSource="{Binding P_OrderList}" >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding IsSelect, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"   Command="{Binding  ElementName=lbOrder,Path=DataContext.DC_OrderSelected}" ToolTip="选择订单" />
            <ListBox ItemsSource="{Binding OrderDetails}" >
                <ListBox.ItemTemplate>
                    <DataTemplate >
                        <CheckBox  IsChecked="{Binding IsSelectGoods, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"   Command="{Binding  ElementName=lbOrder,Path=DataContext.DC_OrderDetailSelected}" ToolTip="选中订单商品"  />
                        <TextBlock Text="{Binding InPrice}">TextBlock>
                    DataTemplate>
                ListBox.ItemTemplate>
            ListBox>
        DataTemplate>
    ListBox.ItemTemplate>
ListBox>

model的定义

public class P_OrderList{
        public Guid Id { get; set; }
        private bool _IsSelect;
        public bool IsSelect
        {
            get { return _IsSelect; }
            set { _IsSelect = value; OnPropertyChanged("IsSelect"); }
        }
        private ObservableCollection _OrderDetails;
        public ObservableCollection OrderDetails
        {
            get { return _OrderDetails; }
            set { _OrderDetails = value; OnPropertyChanged("OrderDetails"); }
        }
}  
  public class OutOrderDetailDto
    {
        public Guid Id { get; set; }
        public Guid OrderId { get; set; }

        private decimal _InPrice;
        public decimal InPrice
        {
            get { return _InPrice; }
            set
            {
                _InPrice = value; OnPropertyChanged("InPrice");
            }
        }
        private bool _IsSelectGoods;
        public bool IsSelectGoods
        {
            get { return _IsSelectGoods; }
            set { _IsSelectGoods = value; OnPropertyChanged("IsSelectGoods"); }
        }
  }

img

遇到的问题

1,选择了左侧商品或者订单的复选框。IsSelect 和IsSelectGoods的值已经发生了变化,但是CheckBox控件没有响应,IsChecked没有响应变化。
2,逻辑层,变更了 InPrice 的值,控件也没有变。

其他都绑定都没有问题,是不是双重绑定导致的?应该怎么解决该?

你用的是communitytoolkit的库对吧,继续添加一个属性依赖库即可。

ItemsSource 也设置 Mode=TwoWay试试 配合 observablecollection

可能是少了消息吧
属性定义

 public class BaseModel : INotifyPropertyChanged
    { 
  private int _isSelect;
public int isSelect
        {
            get { return _isSelect; }
            set { _isSelect= value; OnPropertyChanged(); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged([CallerMemberName]string propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
 

1、参考链接【checkbox选择失效问题】:https://blog.csdn.net/qq_43604714/article/details/116540486