I am using Monotouch dialog with Mvvmcross. My requirement is to have multiple textfield in single element/cell. But in Entryelement we have only one value property which has by default two way binding. Rest of the property are with only one way binding.
I have also tried with UIViewElement but same thing I can bind only one way. UI will update based on changes of ViewModel. But if something user will enter into textfield then how to fire ValueChange for it is challenge for me.
It would be good if somebody can point out rough steps to achieve it.
Related
(I'm using Prism Dryloc) My application consists of two views. The first contains a single list view displaying strings and the second - an entry and a button.
The listview is bound to an observable collection in the first page's View Model. How can I add to the observable collection from a different view?
Great question! You're essentially trying to pass data between views, and there's several ways of passing data between Views in Xamarin.Forms.
The two ways that seem relevant for your case:
Either making the ObservableCollection a public static object (so there's only one global instance of it). Not recommended.
The better way is to use the messaging center so that the second page publishes an event when the button is pressed, that the first page is subscribed to. And it passes that information that gets added to the list.
If these don't work, elaborate your use case and I'll suggest some more
I have a master "gridview" and a detail "gridview" connected to it. The detail "gridview" does not have any columns initially, it loads data from database and it creates its columns.
For example, i'm trying to handle cellvaluechanged event, however, even if i write something in a cell of the gridview and then pressing enter, the event is not firing. What can the reason be?
In my opinion the best way to handle this is: Create a class which represent the data from your database. Let the class implement the interface INotifyPropertyChanged. Then create a BindingList with all Objects from your Database. Now use this BindingList as DataSource for your Grid. The BindingList got the Event ListChanged. This will recognize that a Property Value in your DataSource is changed if you type some new value in cell.
I think this is best practice because you are working with your DataSource and not with GridView directly.
Otherwise the event should fire for sure. If you cant use my idea send some code, maybe i can find the problem then.
regards
I have a button that is inside a view repeated inside a NSCollectionView. I can bind the title of the button to one of the properties in my model class but I want to wire the selector of the button to one of the selectors in my model class. Obviously, the button must send the message to the model object associated with the corresponding collection view item.
I managed to bind the target for the button but how to set the selector? I want to do that in Interface Builder if possible...
I figured it out. In the Ib there is a selector textbox bellow the path textbox where I bind the target. I don't know why I didn't see it. I spent nearly one hour trying to solve this issue.
How to add those blindings? I still can't find it.
I find it . It's Here.
could someone help me with design/understanding the problem: what I need to achieve is page with Panorama/Pivot control, where its items (panos/pivots) will be set via binding, using standard MVVM pattern. Problem is I need to have different content (different user controls) on each pano/pivot, that means If I define a panorama/pivot item template, I doom all of them to be alike, which is not what I want.
I found this question here already asked: Databound windows phone panorama with MVVM design but its still not clear to me. Many thanks.
If you have a dynamic page count on panorama/pivot you could use selector to choose what template is right according to your content.
Implementing DataTemplateSelector
Also, Data Binding Pivot to MVVM may help you too
You could add a dependency property to the user control that you want to use as a data template, a dependency property named "Type" for example and depending on that property you can change the layout of your user control (data template) - for example you could have multiple grids inside your user control and you could show and hide them depending on the type.
I'd like to know how to set a single ViewModel throughout a single UserControl. I'm using an Items container inside a user control (bound to ItemsSource) and it doesn't seem to update with the code-behind replacement of a DataContext (to a code-behind instantiated ViewModel)
What i'm trying to do is change the DataBound foreground color of every text Item in the userControl, and the items inside an Itemscontrol dont seem to change. forcing a datacontext change removed the collection items from display.
I think I'm conceptually Misunderstood here. could anyone help?
I could fix the problem by using Storyboards to change color but the problem was still the same. The eventual solution was to access the resources inside the templates, which is possible by browsing the Visual Tree as shown in this tutorial
http://windowsphonegeek.com/tips/how-to-access-a-control-placed-inside-listbox-itemtemplate-in-wp7
The peculiar thing though, was that I needed to look for my object inside the initial object returned, as it seems to return the System generated one, which you don't see yourself. Looking for the answer inside this one helped. Also, pushing them into a list of items for easy access later could be a general idea, but MS needs to fix the way of doing this pronto.
I would recommend binding the ItemsSource to a property in your ViewModel.