Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF:绑定定制列表框&;列表<;T>;:PropertyChanged始终为空_Wpf_Data Binding_Inotifypropertychanged - Fatal编程技术网

WPF:绑定定制列表框&;列表<;T>;:PropertyChanged始终为空

WPF:绑定定制列表框&;列表<;T>;:PropertyChanged始终为空,wpf,data-binding,inotifypropertychanged,Wpf,Data Binding,Inotifypropertychanged,我已在XAML中声明自定义列表框: <ListBox x:Name="uicMDSQonfServer"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="0,5,0,5"> <CheckBox IsChecked="{Binding Relative

我已在XAML中声明自定义列表框:

<ListBox x:Name="uicMDSQonfServer">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <StackPanel Orientation="Horizontal"
                  Margin="0,5,0,5">
        <CheckBox IsChecked="{Binding RelativeSource={TemplatedParent},
                                      Path=Activated}" />
        <ContentPresenter Content="{Binding RelativeSource={TemplatedParent},
                                    Path=Content}"/>
      </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>
QonfBase是非常简单的基类:

public class QonfBase
{
        private int id;
        public  int ID { get; set; }
}

当我以编程方式打开激活属性时,复选框不更改状态。调试:PropertyChanged=null。有人知道什么是错误的吗?

一个显而易见的问题出现了:
TemplatedParent
用于
ControlTemplate
s。由于您使用的是
数据模板
,因此应该可以:

<CheckBox IsChecked="{Binding Activated}" /> 
<ContentPresenter Content="{Binding Content}"/> 


我没有注意到C#有任何问题。

是否检查输出窗口?有绑定错误吗?谢谢你,雷!我已经删除了显式相对资源,现在它的工作!
<CheckBox IsChecked="{Binding Activated}" /> 
<ContentPresenter Content="{Binding Content}"/>