B는 T가 A 인터페이스를 확장하는 인터페이스 인 BindingList로 고정되어 있습니다. 이 바인딩 목록을 바인딩에 사용할 때 T의 속성 만 표시되고 상속 된 A 인터페이스의 속성은 표시되지 않습니다. 왜 그런가? 닷넷 버그처럼 보입니다. 이 두 가지 프로젝트에 공통된 기능을 공유해야했습니다. 또한 PropertyChanged 이벤트가 baseImplementation에서 터널링 될 때 바인딩 List는 PropertyDescriptor를 비 웁니다. 첨부 된 인터페이스 및 구현. 끝BindingList <T> 여기서 T는 다른 인터페이스를 구현하는 인터페이스입니다.
interface IExtendedInterface : IBaseInterface
{
string C { get; }
}
interface IBaseInterface : INotifyPropertyChanged
{
string A { get; }
string B { get; }
}
public class BaseImplementation : IBaseInterface
{
public string A
{
get { return "Base a"; }
}
public string B
{
get { return "base b"; }
protected set
{
B = value;
OnPropertyChanged("B");
}
}
protected void OnPropertyChanged(string p)
{
if (PropertyChanged != null)
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(p));
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
}
public class ExtendedImplementation : BaseImplementation, IExtendedInterface
{
public string C
{
get { return "Extended C"; }
}
}
private void SetupData()
{
BindingList<IExtendedInterface> list = new BindingList<IExtendedInterface>();
list.Add(new ExtendedImplementation());
list.Add(new ExtendedImplementation());
dataGridView1.DataSource = list;
}
파일에 코드를 첨부하지 마십시오. 우리는 전체 프로젝트가 필요하지 않습니다. 가능한 한 가장 작은 프로그램으로 예제를 분해하고 텍스트/코드로 붙여 넣으십시오. –
'보이지 않음'이란 무엇을 의미합니까? 이러한 속성에 바인딩하는 경우에는 액세스 할 수없는 것으로 나타날 수 있지만 디자인 타임 바인딩의 결과 일 뿐이며 앱을 실행하면 모든 사항이 정상입니다. –
바인딩 된 표에서 ItemChanged 이벤트가 바인딩 목록에서 트리거 될 때 바인딩 된 표에 표시되지 않습니다. BaseInterface의 속성을 고려하면 null PropertyDescriptor가 표시됩니다. 앱이 실행되는 동안 작동하지 않습니다. 코드를 붙여 넣기 만하면됩니다. 내 Rep로 인해 이미지를 게시 할 수 없습니다 – user1079952