event from dll to different project
-
2012년 4월 27일 금요일 오전 7:09
Hallo,
I will make a new attempt on letting my propertygrid notify me when something changes.
So i build a PropertyGrid wich works fine. I made a dll of it and put it into a different project. When i change a property in the propertyGrid the change is wel reflected in my object. What i want to do next is that when i change a property, i would like to notify another class into my project (this is not in the propertygrid itself).
If you look at the class DependencyPropertyInfo, the Value property is what always changes when i change a property from the PropertyGrid. How can i send a mesage or event to my class in the other project that this property or something has changed?
public partial class PropertyGrid : UserControl { public PropertyGrid() { InitializeComponent(); } public ICollectionView GroupedProperties; public void setSelectedObject(object selectedDevice, string dTag) { List<DependencyPropertyInfo> _listProperties = TypeHelper.GetObjectProperties(selectedDevice); GroupedProperties = new ListCollectionView(_listProperties); GroupedProperties.GroupDescriptions.Add(new PropertyGroupDescription("GroupType")); this.DataContext = GroupedProperties; //set name visible txtBlocObjectName.Text = dTag; } }public class DependencyPropertyInfo { private PropertyInfo _descriptor; private object _device; private string categoryAtt; private string description; public DependencyPropertyInfo(PropertyInfo descriptor, string catAtt, string desAtt, object device) { this._descriptor = descriptor; this._device = device; categoryAtt = catAtt; description = desAtt; } public string GroupType { get { return categoryAtt;} } public string Description { get { return description; } } public Type PropertyType { get { return _descriptor.PropertyType; } } public string Name { get { return _descriptor.Name; } } public object Value { get { return _descriptor.GetValue(_device, null); } set { _descriptor.SetValue(_device, value, null); } } }Jc
- 이동됨 Rudedog2MVP 2012년 4월 27일 금요일 오후 6:13 : move to more appropriate forum : (From:Visual C# Language)
- 이동됨 Bob Wu-MTMicrosoft Contingent Staff 2012년 4월 30일 월요일 오전 5:28 (From:Windows Forms General)
모든 응답
-
2012년 4월 30일 월요일 오전 5:27Hi bochelie,
According to your code and your history, it seems that this is a WPF issue. I will move it to the Windows Presentation Foundation (WPF) forum for better support.
Sorry for any inconvenience this may cause.
Best Regards,Bob Wu [MSFT]
MSDN Community Support | Feedback to us
-
2012년 4월 30일 월요일 오전 9:07
Firstluy apologies if I'm not understanding your problem correctly.
To me this sounds like you need to make use of a messenger (Mvvm light toolkit has one).
It sounds like when a property changes you should "send a message" then your class that needs to be notified of this "message" can register to listen to it and then execute a method when it receives this message?
firstly I guess are you aware of the meessenger?
-
2012년 5월 1일 화요일 오전 8:29
I solved this by building an event. So simple, a friend pointed me to that direction. I dont understand why everybody likes that MVVM so much. I think that's a way of thinking. In many cases the MVVM is just overkill.
Thanks to all of you who responded.
Jc

