How can i implement automatic InotifypropertyChanged with LinFu?
Related
Many tutorials and guides suggest that when you create a custom control in Xamarin.Forms or .NET MAUI with a ContentView (or extending another view), it should implement IDisposable interface when needed. See here and here.
That can be useful, as far as i can see, to unsubscribe from events.
My question is: when is Dispose() called?
I tried some scenarios in Xamarin.Forms involving moving from the page where the custom view lies and removing that page from the navigation stack, but none of these actions called the Dispose() method.
Do I have to call it manually?
Solution: Unsubscribe from the message in the message action/handler, or use a pattern of subscribing in OnAppearing and unsubscribing in OnDisappearing.
MessagingCenter.Subscribe<string, DetailClass>(this, "NavigateDetail", async (detail) =>
{
MessagingCenter.Unsubscribe<string>(this, "NavigateDetail");
await Naviation.PopAsync();
});
It seems you have to do it manually.
Javier Suarez answered this question with a Youtube comment under his video.
How can i override wxProcess::OnTerminate function to receive events about process teminating with wxWidgets?
I tried to create class overriding wxProcess and function OnTerminate, but there is no events about it.
How can i override it?
Thanks!
You can either override OnTerminate() in your derived class or handle EVT_PROCESS event. The two are exclusive, i.e. if you override the method you won't get the event. And if you just want to handle the event, there is no need to override anything.
I'm creating an app that has a UITableView.
The data will be comming from an XML fetched over the net. I'm using NSXMLParser for this and it works. I used my tableView controller as the delegate for this so it implements the protocol for it:
#protocol NSXMLParserDelegate;
#interface MainView : UITableViewController <NSXMLParserDelegate>
Now this works perfectly, as I've nslogged the resulting parse.
Now, I want to populate the NStableView, so Reading I find that I need to add the datasource and delegate.
UITableViewDataSource
and
UITableViewDelegate
both of which are protocols.
How would I go about doing this on the same class? can I implement more than one protocol with the same class? should I move the delegation of the parser to another object and use this controller for this purpose?
Basically the question is what is the best way to do this?
thank you
Sure, you can implement as many protocols in a class as you want:
#interface MainView : UITableViewController <NSXMLParserDelegate, UITableViewDataSource, UITableViewDelegate>
Is that the "proper" way of doing that? I don't think there's a "right" answer to that. A purist might say no. I'd say do it where is makes sense, but err on the side of breaking it out into separate classes. For example, if your view controller is a simple menu then it would make sense for your view controller to also be your table view delegate and data source; there's no advantage in breaking it out into multiple classes.
If you have to parse XML my intuition suggests that it's starting to get a bit more complex. Maybe have a data class that implements the data source and XML parser and a controller class?
I'm working on my first C#/WPF project (I'm a Java/Web developer with some Flex/As experience). The MVVM pattern seemed to be the way to go so I've started climbing the learning curve...
I'd like to know what's considered as the way to go to notify state modifications between related ViewModel objects.
Long story short, I have a UserControl containing a TreeView that is bound to a ReadOnlyCollection exposed by MyTreeViewModel.
SomethingViewModel implements INotifyPropertyChanged and generates an event when its 'IsSelected' property is changed.
MyTreeViewModel has an event handler attached to the PropertyChanged event of SomethingViewModel and updates a property that it manages called 'CurrentlySelectedElement'.
MyTreeViewModel also implements INotifyPropertyChanged and generates an event when its 'CurrentlySelectedElement' property changes.
Finally, I have an event handler in another ViewModel class that handles the selection change.
Is this a correct way of approaching this in C#/WPF?
Also, I'm not really fond of using property names with Strings in my event handling methods; It doesn't seem very refactoring friendly to me.. For now, I've dealt with this by exposing the property name as a static string, so that I can simply use the following in my event handler method:
if(SomeViewModel.PROPERTY_IS_SELECTED.Equals(e.PropertyName)) { ... }
Do you know a better alternative? I guess there should be a way of doing this but to be honest I didn't investigate that any further yet.
Thanks for your feedback!
Check out the Event Aggregator pattern. There are quite a few implementations out there. If you're using a MVVM framework ( https://stackoverflow.com/questions/1280462/what-mvvm-framework-are-you-using, What framework for MVVM should I use? ), chances are it will contain an implementation as well.
I want to implement MVC architicture in my project. So I have to implement NSObject class for NSTableView.But some delegate method is not called. How to implement this class? Please help me for this issue.
The Table View Programming Guide can teach you what you need to know.
The NSTableView class reference page lists some sample code for you to try out on your own