Есть модель:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
public class CircleModel : ICircleModel, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
double _radius;
public double Radius
{
get
{
return _radius;
}
set
{
if (_radius == value) return;
_radius = value;
RaisePropertyChanged("Radius");
}
}
........................................................
раньше было так:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
ICircleModel_model = new CircleModel();
public ICircleModelViewModel
{
get
{
return DataContext as ICircleModel;
}
set
{
DataContext = value;
}
}
public MainWindow()
{
InitializeComponent();
DataContext = ViewModel;
ViewModel = _model;
}
1.
2.
3.
4.
5.
6.
7.
8.
<Grid Margin="100 20 0 0"
Width="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeGridConverter}}"
Height="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeGridConverter}}"
MouseRightButtonDown="ZodiacCtrl_MouseRightButtonDown">
<zodiac:Zodiac x:Name="ZodiacCtrl" Panel.ZIndex="1" Model="{Binding}"
Width="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeConverter}}"
Height="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeConverter}}"
Loaded="rtc1_Loaded" SizeChanged="rtc1_SizeChanged"/>
Все работало отлично!
Потом понадобилось добавить больше данных в модель и она теперь стала такого вида:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
public class DataModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
List<TableRow> _data = new List<TableRow>();
public List<TableRow> Data
{
get
{
return _data;
}
set
{
if (_data == value) return;
_data = value;
RaisePropertyChanged("Data");
}
}
ICircleModel _zodiac = new CircleModel();
public ICircleModel ZodiacModel
{
get
{
return _zodiac;
}
set
{
if (_zodiac == value) return;
_zodiac = value;
RaisePropertyChanged("ZodiacModel");
}
}
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
DataModel _model = new DataModel();
public DataModel ViewModel
{
get
{
return DataContext as DataModel;
}
set
{
DataContext = value;
}
}
1.
2.
3.
4.
5.
6.
7.
8.
<Grid Margin="100 20 0 0"
Width="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeGridConverter}}"
Height="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeGridConverter}}"
MouseRightButtonDown="ZodiacCtrl_MouseRightButtonDown">
<zodiac:Zodiac x:Name="ZodiacCtrl" Panel.ZIndex="1" Model="{Binding Path=ZodiacModel, Mode=OneWay}"
Width="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeConverter}}"
Height="{Binding ElementName=window, Path=ActualHeight, Converter={StaticResource SizeConverter}}"
Loaded="rtc1_Loaded" SizeChanged="rtc1_SizeChanged"/>
Но теперь UI не обновляются. zodiac:Zodiac это кастомный контрол.
Где что не так сделано, что подкрутить надо?