Event triggering an event [closed]
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I've got a little application that I've dumbed down to show you the basics of what an excel reader would look like for new foods, consisting of Fruits and Meats.
The Application is written in WPF, C# and follows the MVVM architecture.
So on my main window I have a Create
button, that I want to set disabled if something from both lists isn't valid. These lists are resided inside a user control that hosts both lists in 2 data grids.
How I currently handle this is that I let the OnPropertyChanged
event from my objects trigger an event for the entire lists, that triggers an event for the entire user control that triggers an event for the main window which then checks if all sub items are valid.
This works and lets me very easily expand this check without using duplicate data.
However I'm not sure that events triggering other events in a tree, especially this big, is considered 'Good Practice'. So that's why I thought of asking some help from the code gods.
You can see dumbed down version of what I'm currently doing bellow.
Main Window
public void Init(ImportType type)
var view = new FoodView();
SelectedView = view;
SelectedView.CollectionItemChanged += (s, e) => RaisePropertyChanged(nameof(CheckErrors));
User control food
public class FoodViewModel : ObservableObject, IImporter
public event PropertyChangedEventHandler CollectionItemChanged;
private FoodFileProcessor rfp;
public void SetFileAsync(string fullFilePath)
rfp.FoodCollectionItemChanged += (s, e) => OnCollectionItemChanged(s, e);
// Open and process the file passed
Task.Run(() => rfp.OpenFile(fullFilePath));
File processing
public class MeatFileProcessor
public event PropertyChangedEventHandler MeatsCollectionItemChanged;
public ObservableCollection<Fruit> NewFruits = new ObservableCollection<Fruit>();
public ObservableCollection<Meat> NewMeats = new ObservableCollection<Meat>();
public void OpenFile(string filePath)
using (var xlApp = new ExcelPackage(new FileInfo(filePath)))
FruitTabProcessor.ListItemProperyChanged += (s, e) => OnFruitsCollectionChanged(s, e); ;
ObservableCollection<Fruit> fruits = FruitTabProcessor.FormatFruit(xlApp.Workbook.Worksheets[2]);
NewFruits = fruits;
MeatTabProcessor.ListItemProperyChanged += (s, e) => OnMeatsCollectionChanged(s, e); ;
var meats = MeatTabProcessor.FormatMeat(xlApp.Workbook.Worksheets[1]);
NewMeats = meats;
}
This is then an example of where a food object would get created, for example meat.
private static void NewMeat(Meat meat)
meat.PropertyChanged += Meat_PropertyChanged;
private static void Meat_PropertyChanged(object sender, PropertyChangedEventArgs e)
OnListItemPropertyChanged(sender, e);
protected static void OnListItemPropertyChanged(object s, PropertyChangedEventArgs e)
ListItemProperyChanged?.Invoke(s, e);
I was wondering if this is fine or if there is a better way of handling this situation? Is it OK to have events trigger other events because this kind of feels like a bad thing to do. I've read about the dangers of getting in a deadlock but seeing that this doesn't really do anything other then notifying change, this wouldn't be an issue.
c# event-handling wpf mvvm
closed as off-topic by t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno Apr 5 at 14:32
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." â t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno
add a comment |Â
up vote
1
down vote
favorite
I've got a little application that I've dumbed down to show you the basics of what an excel reader would look like for new foods, consisting of Fruits and Meats.
The Application is written in WPF, C# and follows the MVVM architecture.
So on my main window I have a Create
button, that I want to set disabled if something from both lists isn't valid. These lists are resided inside a user control that hosts both lists in 2 data grids.
How I currently handle this is that I let the OnPropertyChanged
event from my objects trigger an event for the entire lists, that triggers an event for the entire user control that triggers an event for the main window which then checks if all sub items are valid.
This works and lets me very easily expand this check without using duplicate data.
However I'm not sure that events triggering other events in a tree, especially this big, is considered 'Good Practice'. So that's why I thought of asking some help from the code gods.
You can see dumbed down version of what I'm currently doing bellow.
Main Window
public void Init(ImportType type)
var view = new FoodView();
SelectedView = view;
SelectedView.CollectionItemChanged += (s, e) => RaisePropertyChanged(nameof(CheckErrors));
User control food
public class FoodViewModel : ObservableObject, IImporter
public event PropertyChangedEventHandler CollectionItemChanged;
private FoodFileProcessor rfp;
public void SetFileAsync(string fullFilePath)
rfp.FoodCollectionItemChanged += (s, e) => OnCollectionItemChanged(s, e);
// Open and process the file passed
Task.Run(() => rfp.OpenFile(fullFilePath));
File processing
public class MeatFileProcessor
public event PropertyChangedEventHandler MeatsCollectionItemChanged;
public ObservableCollection<Fruit> NewFruits = new ObservableCollection<Fruit>();
public ObservableCollection<Meat> NewMeats = new ObservableCollection<Meat>();
public void OpenFile(string filePath)
using (var xlApp = new ExcelPackage(new FileInfo(filePath)))
FruitTabProcessor.ListItemProperyChanged += (s, e) => OnFruitsCollectionChanged(s, e); ;
ObservableCollection<Fruit> fruits = FruitTabProcessor.FormatFruit(xlApp.Workbook.Worksheets[2]);
NewFruits = fruits;
MeatTabProcessor.ListItemProperyChanged += (s, e) => OnMeatsCollectionChanged(s, e); ;
var meats = MeatTabProcessor.FormatMeat(xlApp.Workbook.Worksheets[1]);
NewMeats = meats;
}
This is then an example of where a food object would get created, for example meat.
private static void NewMeat(Meat meat)
meat.PropertyChanged += Meat_PropertyChanged;
private static void Meat_PropertyChanged(object sender, PropertyChangedEventArgs e)
OnListItemPropertyChanged(sender, e);
protected static void OnListItemPropertyChanged(object s, PropertyChangedEventArgs e)
ListItemProperyChanged?.Invoke(s, e);
I was wondering if this is fine or if there is a better way of handling this situation? Is it OK to have events trigger other events because this kind of feels like a bad thing to do. I've read about the dangers of getting in a deadlock but seeing that this doesn't really do anything other then notifying change, this wouldn't be an issue.
c# event-handling wpf mvvm
closed as off-topic by t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno Apr 5 at 14:32
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." â t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno
3
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
1
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I've got a little application that I've dumbed down to show you the basics of what an excel reader would look like for new foods, consisting of Fruits and Meats.
The Application is written in WPF, C# and follows the MVVM architecture.
So on my main window I have a Create
button, that I want to set disabled if something from both lists isn't valid. These lists are resided inside a user control that hosts both lists in 2 data grids.
How I currently handle this is that I let the OnPropertyChanged
event from my objects trigger an event for the entire lists, that triggers an event for the entire user control that triggers an event for the main window which then checks if all sub items are valid.
This works and lets me very easily expand this check without using duplicate data.
However I'm not sure that events triggering other events in a tree, especially this big, is considered 'Good Practice'. So that's why I thought of asking some help from the code gods.
You can see dumbed down version of what I'm currently doing bellow.
Main Window
public void Init(ImportType type)
var view = new FoodView();
SelectedView = view;
SelectedView.CollectionItemChanged += (s, e) => RaisePropertyChanged(nameof(CheckErrors));
User control food
public class FoodViewModel : ObservableObject, IImporter
public event PropertyChangedEventHandler CollectionItemChanged;
private FoodFileProcessor rfp;
public void SetFileAsync(string fullFilePath)
rfp.FoodCollectionItemChanged += (s, e) => OnCollectionItemChanged(s, e);
// Open and process the file passed
Task.Run(() => rfp.OpenFile(fullFilePath));
File processing
public class MeatFileProcessor
public event PropertyChangedEventHandler MeatsCollectionItemChanged;
public ObservableCollection<Fruit> NewFruits = new ObservableCollection<Fruit>();
public ObservableCollection<Meat> NewMeats = new ObservableCollection<Meat>();
public void OpenFile(string filePath)
using (var xlApp = new ExcelPackage(new FileInfo(filePath)))
FruitTabProcessor.ListItemProperyChanged += (s, e) => OnFruitsCollectionChanged(s, e); ;
ObservableCollection<Fruit> fruits = FruitTabProcessor.FormatFruit(xlApp.Workbook.Worksheets[2]);
NewFruits = fruits;
MeatTabProcessor.ListItemProperyChanged += (s, e) => OnMeatsCollectionChanged(s, e); ;
var meats = MeatTabProcessor.FormatMeat(xlApp.Workbook.Worksheets[1]);
NewMeats = meats;
}
This is then an example of where a food object would get created, for example meat.
private static void NewMeat(Meat meat)
meat.PropertyChanged += Meat_PropertyChanged;
private static void Meat_PropertyChanged(object sender, PropertyChangedEventArgs e)
OnListItemPropertyChanged(sender, e);
protected static void OnListItemPropertyChanged(object s, PropertyChangedEventArgs e)
ListItemProperyChanged?.Invoke(s, e);
I was wondering if this is fine or if there is a better way of handling this situation? Is it OK to have events trigger other events because this kind of feels like a bad thing to do. I've read about the dangers of getting in a deadlock but seeing that this doesn't really do anything other then notifying change, this wouldn't be an issue.
c# event-handling wpf mvvm
I've got a little application that I've dumbed down to show you the basics of what an excel reader would look like for new foods, consisting of Fruits and Meats.
The Application is written in WPF, C# and follows the MVVM architecture.
So on my main window I have a Create
button, that I want to set disabled if something from both lists isn't valid. These lists are resided inside a user control that hosts both lists in 2 data grids.
How I currently handle this is that I let the OnPropertyChanged
event from my objects trigger an event for the entire lists, that triggers an event for the entire user control that triggers an event for the main window which then checks if all sub items are valid.
This works and lets me very easily expand this check without using duplicate data.
However I'm not sure that events triggering other events in a tree, especially this big, is considered 'Good Practice'. So that's why I thought of asking some help from the code gods.
You can see dumbed down version of what I'm currently doing bellow.
Main Window
public void Init(ImportType type)
var view = new FoodView();
SelectedView = view;
SelectedView.CollectionItemChanged += (s, e) => RaisePropertyChanged(nameof(CheckErrors));
User control food
public class FoodViewModel : ObservableObject, IImporter
public event PropertyChangedEventHandler CollectionItemChanged;
private FoodFileProcessor rfp;
public void SetFileAsync(string fullFilePath)
rfp.FoodCollectionItemChanged += (s, e) => OnCollectionItemChanged(s, e);
// Open and process the file passed
Task.Run(() => rfp.OpenFile(fullFilePath));
File processing
public class MeatFileProcessor
public event PropertyChangedEventHandler MeatsCollectionItemChanged;
public ObservableCollection<Fruit> NewFruits = new ObservableCollection<Fruit>();
public ObservableCollection<Meat> NewMeats = new ObservableCollection<Meat>();
public void OpenFile(string filePath)
using (var xlApp = new ExcelPackage(new FileInfo(filePath)))
FruitTabProcessor.ListItemProperyChanged += (s, e) => OnFruitsCollectionChanged(s, e); ;
ObservableCollection<Fruit> fruits = FruitTabProcessor.FormatFruit(xlApp.Workbook.Worksheets[2]);
NewFruits = fruits;
MeatTabProcessor.ListItemProperyChanged += (s, e) => OnMeatsCollectionChanged(s, e); ;
var meats = MeatTabProcessor.FormatMeat(xlApp.Workbook.Worksheets[1]);
NewMeats = meats;
}
This is then an example of where a food object would get created, for example meat.
private static void NewMeat(Meat meat)
meat.PropertyChanged += Meat_PropertyChanged;
private static void Meat_PropertyChanged(object sender, PropertyChangedEventArgs e)
OnListItemPropertyChanged(sender, e);
protected static void OnListItemPropertyChanged(object s, PropertyChangedEventArgs e)
ListItemProperyChanged?.Invoke(s, e);
I was wondering if this is fine or if there is a better way of handling this situation? Is it OK to have events trigger other events because this kind of feels like a bad thing to do. I've read about the dangers of getting in a deadlock but seeing that this doesn't really do anything other then notifying change, this wouldn't be an issue.
c# event-handling wpf mvvm
edited Apr 5 at 12:49
t3chb0t
32k54195
32k54195
asked Apr 4 at 11:48
Ben
93
93
closed as off-topic by t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno Apr 5 at 14:32
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." â t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno
closed as off-topic by t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno Apr 5 at 14:32
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." â t3chb0t, Sam Onela, Stephen Rauch, Imus, Dannnno
3
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
1
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36
add a comment |Â
3
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
1
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36
3
3
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
1
1
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Couple of comments.
Look into ICommand, I use this nuget package https://www.nuget.org/packages/RelayCommand
This allows you to:
public ICommand SomeCommand => new RelayCommand<SomeType>(DoSomething, x => CanDoSomething());
public void DoSomething(SomeType parameter)
//ToDo: Implement me
public bool CanDoSomething()
//ToDo: Implement me
When you can't do something (Items not selected for example) then your button will disable automatically.
Couple notes on ObservableCollection. This will notify you when an item is added.
The object that you add and remove need to implement INotifyProperty changed so you can monitor changes in your view to your objects.
You are using alot of event handler subscriptions - but you aren't unsubscribing - this may lead to memory leaks. Leverage ICommand where possible to avoid leaks.
I'm not sure if this is correct of not but your FruitTabProcessor Property changed handler is subscribing to OnMeats shouldn't it subscribe to OnFruits?
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Couple of comments.
Look into ICommand, I use this nuget package https://www.nuget.org/packages/RelayCommand
This allows you to:
public ICommand SomeCommand => new RelayCommand<SomeType>(DoSomething, x => CanDoSomething());
public void DoSomething(SomeType parameter)
//ToDo: Implement me
public bool CanDoSomething()
//ToDo: Implement me
When you can't do something (Items not selected for example) then your button will disable automatically.
Couple notes on ObservableCollection. This will notify you when an item is added.
The object that you add and remove need to implement INotifyProperty changed so you can monitor changes in your view to your objects.
You are using alot of event handler subscriptions - but you aren't unsubscribing - this may lead to memory leaks. Leverage ICommand where possible to avoid leaks.
I'm not sure if this is correct of not but your FruitTabProcessor Property changed handler is subscribing to OnMeats shouldn't it subscribe to OnFruits?
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
add a comment |Â
up vote
0
down vote
Couple of comments.
Look into ICommand, I use this nuget package https://www.nuget.org/packages/RelayCommand
This allows you to:
public ICommand SomeCommand => new RelayCommand<SomeType>(DoSomething, x => CanDoSomething());
public void DoSomething(SomeType parameter)
//ToDo: Implement me
public bool CanDoSomething()
//ToDo: Implement me
When you can't do something (Items not selected for example) then your button will disable automatically.
Couple notes on ObservableCollection. This will notify you when an item is added.
The object that you add and remove need to implement INotifyProperty changed so you can monitor changes in your view to your objects.
You are using alot of event handler subscriptions - but you aren't unsubscribing - this may lead to memory leaks. Leverage ICommand where possible to avoid leaks.
I'm not sure if this is correct of not but your FruitTabProcessor Property changed handler is subscribing to OnMeats shouldn't it subscribe to OnFruits?
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Couple of comments.
Look into ICommand, I use this nuget package https://www.nuget.org/packages/RelayCommand
This allows you to:
public ICommand SomeCommand => new RelayCommand<SomeType>(DoSomething, x => CanDoSomething());
public void DoSomething(SomeType parameter)
//ToDo: Implement me
public bool CanDoSomething()
//ToDo: Implement me
When you can't do something (Items not selected for example) then your button will disable automatically.
Couple notes on ObservableCollection. This will notify you when an item is added.
The object that you add and remove need to implement INotifyProperty changed so you can monitor changes in your view to your objects.
You are using alot of event handler subscriptions - but you aren't unsubscribing - this may lead to memory leaks. Leverage ICommand where possible to avoid leaks.
I'm not sure if this is correct of not but your FruitTabProcessor Property changed handler is subscribing to OnMeats shouldn't it subscribe to OnFruits?
Couple of comments.
Look into ICommand, I use this nuget package https://www.nuget.org/packages/RelayCommand
This allows you to:
public ICommand SomeCommand => new RelayCommand<SomeType>(DoSomething, x => CanDoSomething());
public void DoSomething(SomeType parameter)
//ToDo: Implement me
public bool CanDoSomething()
//ToDo: Implement me
When you can't do something (Items not selected for example) then your button will disable automatically.
Couple notes on ObservableCollection. This will notify you when an item is added.
The object that you add and remove need to implement INotifyProperty changed so you can monitor changes in your view to your objects.
You are using alot of event handler subscriptions - but you aren't unsubscribing - this may lead to memory leaks. Leverage ICommand where possible to avoid leaks.
I'm not sure if this is correct of not but your FruitTabProcessor Property changed handler is subscribing to OnMeats shouldn't it subscribe to OnFruits?
answered Apr 5 at 9:32
d347hm4n
576515
576515
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
add a comment |Â
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
Hi d347hm4n, Thank you for your feedback, I am indeed using the ICommand for my button specifically, the "CanDoSomething()" will climb back up the tree to check if all entries are valid. The reason however for utilizing these events is to indicate that something has changed and the "CanDoSomething()" should check if the lists are still valid. The problem was originally that the objects meat and fruit can't notify the main view that it needs to check if "CanDoSomething()" is valid. Regarding mem leak, wont creating an object and placing it in the variable result in the GC cleaning the old var?
â Ben
Apr 5 at 11:00
1
1
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
@Ben I am indeed using the ICommand for my button specifically - this is exactly why should shouldn't post edited code. It's verly likely that reviews will suggest solutions that you already have.
â t3chb0t
Apr 5 at 12:52
add a comment |Â
3
You can see dumbed down version - this is not good, Code Review requires real code.
â t3chb0t
Apr 5 at 12:50
1
I partially agree with techbot. You can ommit parts of the code that are really similar to focus on the important parts for the review. But if you change code just for the review we risk the situation where you get an unsatisfactory answer from us and then reply yourself with "but my actual code doesn't look like this". That situation just a waste of time for everybody. If you think this code is similar enough to your original that it this situation won't happen you could edit out the "dumbed down" part and hint at parts you omitted if needed.
â Imus
Apr 5 at 13:36