Не Отслеживается Изменение Зависимого Свойства

11.05.2013
10
0
#1
Есть 2 компонента, соединяемых по зависимому свойству класса
Код:
public class StackerWorkData : INotifyPropertyChanged 
{
private Int32 _X;
public Int32 X
{
get
{
return _X;
}
set
{
_X = value;
OnPropertyChanged("X");
}
}

private Int32 _Y;
public Int32 Y
{
get
{
return _Y;
}
set
{
_Y = value;
OnPropertyChanged("Y");
}
}


private Int32 _Z;
public Int32 Z
{
get
{
return _Z;
}
set
{
_Z = value;
OnPropertyChanged("Z");
}
}

private Int32 _cell;
public Int32 Cell
{
get
{
return _cell;
}
set
{
_cell = value;
OnPropertyChanged("Cell");
}
}

private StackerCommand _cmd;
public StackerCommand cmd
{
get
{
return _cmd;
}
set
{
_cmd = value;
OnPropertyChanged("cmd");
}
}


/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Called when [property changed].
/// </summary>
/// <param name="name">The name.</param>
private void OnPropertyChanged(string name)
{
if (PropertyChanged != null)//BiopsyCore
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}


}
в компоненте StackerManBNR:
Код:
// Dependency Property
public static readonly DependencyProperty WorkParamsDP = DependencyProperty.Register("WorkParams", typeof(ItemsChangeObservableCollection<StackerWorkData>), typeof(StackerManBNR), new FrameworkPropertyMetadata(null, DepParamsChanged));
// .NET Property wrapper
public ItemsChangeObservableCollection<StackerWorkData> WorkParams
{
get
{
return (ItemsChangeObservableCollection<StackerWorkData>)GetValue(WorkParamsDP);
}
private set { 
SetValue(WorkParamsDP, value); 
}
}
в компоненте StackerControl :
Код:
// Dependency Property
public static readonly DependencyProperty WorkParamsDP = DependencyProperty.Register("WorkParams", typeof(ItemsChangeObservableCollection<StackerWorkData>), typeof(StackerControl), new UIPropertyMetadata(null, DepParamsChanged));
// .NET Property wrapper
private static readonly DependencyPropertyDescriptor WorkparamsDP_PD = DependencyPropertyDescriptor.FromProperty(WorkParamsDP, typeof(StackerControl));
[Description("Stacker parameters"), Category("Stacker")]
public ItemsChangeObservableCollection<StackerWorkData> WorkParams
{
get
{
return (ItemsChangeObservableCollection<StackerWorkData>)GetValue(WorkParamsDP);
}
set { SetValue(WorkParamsDP, value); }
}

private static void DepParamsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
StackerControl ctrl = (StackerControl)d;
if (e.Property.Name == "WorkParams")
{ 

}
ctrl.SetParam(e.Property.Name, e.NewValue, e.OldValue);

}

...
case "WorkParams":
try
{
LoadConfig();
var rd = (from c in this.Coords_Points where (Convert.ToInt32(c.Attribute("X").Value) >= WorkParams[0].X) orderby c.Attribute("X").Value select c).ToList<XElement>();
Int32 col = GetButtonX(Convert.ToInt32(rd[0].Attribute("ID").Value));
Grid.SetColumn(stacker_base,col);
}
catch (System.Exception exc)
{ 
}
break;
...
WorkParams = new ItemsChangeObservableCollection<StackerWorkData>();
//WorkParams.CollectionChanged += new NotifyCollectionChangedEventHandler(WorkParams_CollectionChanged);
WorkParams.Add(new StackerWorkData());

WorkparamsDP_PD.AddValueChanged(this, delegate
{ 

});
StackerControl слушает свойство WorkParams контрола StackerManBNR.
Код:
<my:StackerControl ... WorkParams="{Binding ElementName=stacker1_man, Path=WorkParams}"></my:StackerControl>
Свойство WorkParams изменяется, но момент изменения этого свойства, в частности когда меняются X,Y,Z не улавливается программой. То есть при изменении свойства класса не срабатывает PropertyChangedCallbacк