0
我已經自定義列表框在XAML聲明:WPF:綁定自定義列表框和列表<T>:的PropertyChanged總是空
<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>
我需要dsiplay和互操作與泛型列表,其中T是:
public class QonfServer: QonfBase, INotifyPropertyChanged
{
private string ip;
private bool activated;
public string Ip {
get { return ip; }
}
public bool Activated
{
get { return activated; }
set
{
if (activated == value)
return;
activated = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Activated"));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
QonfBase是很簡單的基類:
public class QonfBase
{
private int id;
public int ID { get; set; }
}
當我打開ACTIV ated屬性編程,複選框不改變狀態。調試:PropertyChanged = null。任何人都知道,什麼是不正確的?
你檢查輸出窗口?有沒有綁定錯誤? – 2010-01-21 08:19:53
沒有綁定錯誤。 – Pavel 2010-01-21 08:47:51