Ticket T352298
Visible to All Users

Data binding in Xamarin.Forms

created 9 years ago

Can you help me understand data binding a little better with your grid?

In our code we are simply targeting iOS only with Xamarin Forms and as such in the code behind of the XAML form we populate a list of a model and then set the binding context …you are doing an MVVM style in your demo

I have a List<Customer> …how do I bind it to your grid?

I have tried and it seems to select the first row and not allow me to select any other row in the grid

Comments (2)
DevExpress Support Team 9 years ago

    Hi,

    I am afraid your scenario is not clear to me. Would you please explain it in greater detail or provide me with a sample project? It will be very helpful for me. I am looking forward to your response.

    Thanks
    Alex

    SH SH
    Stephen Hauck 1 9 years ago

      I have a customer model…no code at all.
      I have database io code that returns a List<Customer> object
      In a Xamarin Forms app you simply set the binding context and then bind in the XAML like such

      //Get the stops
      var allStops = new  Database ().GetAllStops ();

      //Set the binding
      BindingContext = allStops;
      listViewStops.ItemsSource = allStops;

      Then in the XAML you simply bind the elements
      <Label Text="{Binding CustName}"></Label>
      This code works with Xamarin Forms but not with your grid.

      Answers approved by DevExpress Support

      created 9 years ago

      Hi Stephen,

      As far as I understand, you just need to show your data objects in our GridControl. You can set the grid's ItemsSource property like the same property of the ListView, but then you try to show properties of your data objects in Grid rows using templates like in the ListView. If so, we have another approach for data showing, and you don't need to create bindings for this. Simply create columns for each required data property and set the FieldName property of these columns. In this property, write the required data object property name. Please refer to the following help article to get more detailed information about columns: Columns Overview.

      Thanks
      Alex

        Show previous comments (6)
        SH SH
        Stephen Hauck 1 9 years ago

          Again… as I stated previously … it does load the data but it does not allow you to select rows in the grid in any way

          DevExpress Support Team 9 years ago

            Hi Stephen,

            Would you please clarify how you change selected rows? Do you tap on rows, and a tapped row isn't selected, or do you do something else?

            Thanks
            Alex

            SH SH
            Stephen Hauck 1 9 years ago

              I tried to tap to select a row…it's ok…Iv'e spent too much time on this already.
              Have a good one

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.