I've got a Silverlight client and I'm using MVVM. I've put in my first View and View Model. The View binds to the View Model. I now want to localise the text of all the controls. For example my View has a button which contains the text "Search". I know I need to bind the Text content property of the button to something to provide the correct text. The question is what? Do I provide a property in the View Model called SearchButtonText and bind it to that(where the SearchButtonText property returns a resource string)? Or is this taking it too far in terms of what the View Model does and instead bind to a resource string in the View namespace, even though the root level binding for the View is the View Model?
Any help much appreciated!
Cheers
Bind to a resource string in the view.
Related
Suppose I have a view
How can I get a control of this view by Id from a different controller.
I have tried to set up an ID for the view and tried to access the view by
sap.ui.getCore().byId("mainViewID") in another controller but it didnt work.
It took only the dynamic view id what you can find from the html elements.
Getting a control from another view is discouraged and is generally indicative of bad design.
In case what you need to do is access data in another view or to change a property of a control based on user input, the better method is to bind those properties to a model and then access that model from the second view.
You can do this by attaching the model to the core, thereby making it accessible throughout the application. For example:
var oModel = new sap.ui.model.json.JSONModel();
this.getCore.setModel(oModel,"modelName");
Alternatively, you can create this model in the manifest file.
I have a view, I have bind this view to a view Model having list items.
When I make any changes to view Model corresponding changes I could see in view.
But when I remove an item from view it is not getting updated in viewModel.
I am using KendoUi for above.
Can any one please let me know what is the issue here
I assume ViewModel collection is of type ObservableCollection. Use a two-way binding to accomplish what you need.
ItemsSource = {Binding Path=MyCollection, Mode=TwoWay}
I am just starting out on iOS(from Android) and I am having trouble figuring out how to pass data between views in tabs. I've included pictures to describe my question in a little more detail; how can I get the map type to change when one of the selectors is changed or the user location to appear/disappear when the boolean switch is ticked?
One tab is a map tab:
The Other is a selector:
The quick answer is that you have the view controllers talk to each other.
Edit: I knew I'd have to come back.
It depends on where you are starting from.
But This thread seems to be popular and has an example project. It might need tweaking to use a more modern iOS version - but it does provide the general idea.
One way to do it in your application, is to have properties on the view controller that shows the map as to the type of view it displays, and whether or not the current location is shown. Then, from your selector's view controller set those properties.
How do you get the map's view controller - pass it to the selector's controller at creation. Resist the temptation to have the map controller be a property of the Application delegate. It's an easy way of passing it around, but it breaks encapsulation IMO.
As an aside.
As you progress, you'll realise that the way to do this is to have the controls overlaid on the map view as subviews. Not only is that a better UI (all the changes can be made in place), but then as you are on the same view, you don't need to use a different view controller, and there is no need to be passing around object pointers. :)
You should check out this thread for a very detailed description of each possible method:
What's the best way to communicate between view controllers?
You will have to use NSNotifications or NSUserDefaults
Check objective-c updating data from a different view
For this type of "Settings" view, I'd create a custom protocol and set your map view as the delegate object in your settings view. Let me know if you need code.
Well, my first answer would be that a tabbed interface probably isn't appropriate here. Tab bars are to provide parallel modes of usage (e.g a watch app that shows either an alarm or a timer), not to provide subsidiary information. You should probably have a button on the mapview that pulls up a modal dialog to change the settings. That then uses a delegate pattern to send the changed information back to the parent. See apple's document on Modal View Controllers for sample code.
i have a view which is fetching data from an Array and presenting the data in a tableview. This view has a navigation controller with a button in it. The button is meant to take you to another view for advanced searching. Let's say that in this new view i have a picker, when the user selects a value from the picker and clicks the back button in the navigation bar i want to get the value that the user selected. What is the best practice to do that? How can i send the selected value from one activity to the previous one?
Thanks in advance.
What you need here is reasoning a bit in terms of the Model-View-Controller design pattern.
Views should get their data through the model. So in your advanced search view, when the user selects some value, this value is stored in the model.
When you go back, the first view redraw itself by reading the current search value from the model.
There are other possibilities, like having the search view controller own a pointer to the first view and sending a message to it when the search value changes, but this is not very modular and is pretty fragile.
Use delegation. Write your own protocol like "PickerViewDelegate". then implement this protocol in your "main view" (which has table view). in PickerView just invoke [delegate somethingPicked:something].
I'm not sure, that search value is a model entity.
Using Interface Builder, how do I sequence the tabs so they flow from right to left, top to bottom?
One basic idea is to implement UITextFieldDelegate's textFieldShouldReturn: method, and either
Check the textField object against the outlet properties that you assign to your text fields using IB, or
Check textField.tag against the tags you assign to your text fields using IB or within your view controller's code
Then switch first responders accordingly. You can't tell your view controller the general direction to go and it'll know which text fields to switch (AppKit probably does this through guesswork, but I don't think UIKit does the same), but you can make use of outlets or tags to identify your text fields.