UWP-040 - Data Binding to the GridView and ListView Controls

Play UWP-040 - Data Binding to the GridView and ListView Controls

The Discussion

  • User profile image

    HI Bob,

    Great series.
    I have been watching, reviewing, performing the exercises, and documenting each section.

    This lesson UWP-040, although, has found me stuck. As I could not get my code to work, I ended up copying your code (Book.cs, MainPage.xaml, MainPage.xaml.cs) and still had the same issue. If you could please share your thoughts, I would be greatly appreciative.

    Issue: with the following: <DataTemplate x:DataType="data:Book">
    error message: The name "Book" does not exist in the namespace "using:xBindDataExample.Models".

  • User profile image

    @Dan: I'm willing to bet that either (1) your folder is named Model, not Models, or (2) the Book class is not in the Models namespace.  I would take a close look at the Book class definition, the EXACT name of the folder, namespace, class.  If it's not that, then I would probably need to see your code.

  • User profile image

    Hi Bob,

    Thank you for your quick response. I was able to get the same code working, without any changes, by completing the following:

    1. Exiting out of VS 2015
    2. Launching the project (xBindDataExample)
    3. Without editing the code, Running the Code.
    3a. If I tried to edit the code, before running, I received the squiggly line under the x:DataType bind name.
    4. I can now continue to edit the code.

    Note: If I edit the class name and the DataType bind to that new name, I get the squiggly line error again. Exiting out of VS and running code as soon as I enter the project seems to correct the issue again and allow me to continue.

    I can't explain this strange occurrence, but thank you again for your quick response. I have so many ideas for applications; I am excited about learning through your series and starting my adventures.

  • User profile image

    @Dan: I think I see what's going on here ... sometimes that XAML parser (??) needs the classes in your app COMPILED into an assembly BEFORE it can "see" those types.  Thanks for the nice words!

  • User profile image

    Bob, this is odd. I am making my own app (Universal Windows)

    And when I compile my XAML with my Gridview, including this "ItemsSource="{x:bind teamRow3}"

    The compiler complains "Error  bind is not supported in a Windows Universal project"

    Any idea why I cannot use x:bind in my own Universal App?

    RESOLVED: its x:Bind    (it needs an upper case B) what a horrible compiler message :)


  • User profile image

    I really got stuck over here. 

    When you create your Book under Model, does it mean that your Model updates the View? I thought Windows follows MVVM and we would require a ViewModel class to link to the view. This is what confuses me.

  • User profile image

    @BobTabor: I think a comment should be made that before continuing at 3:07 You should build your project. In order to get that class being compiled.
    As I have seen a lot of Bob's excellent screencasts I know he is a fan or rebuilding and saving all files a lot. That made me figuring this out. (a) Just copy his behavior it's all build on years of experience!
    I can't say this enough, Bob you are an awesome teacher! Keep it up!

  • User profile image

    Hi Bob,

    Thank you for the great videos. I really need help on the listview. Many samples out there describe

    Well the problem is, the headertemplate does not exist. I really need help on how to do grouping in listview which leads to how to use semanticzoom. If you could help me out.
  • User profile image

    Mauriez is absolutely correct - to allow recognize book class in nameSpase- it MUST be Build before...

  • User profile image

    This explained a lot about gridviews to me, thanks. I have a question though. Let's say I want to update one of the items in the gridview. For example, I add a button, and set that buttons action to this:

    Books[0].Title = "hello";

    If this was outside of the gridview, it would update, however, the gridview does not show "hello" for the title of the first book. How would I get this behavior?

  • User profile image

    Hey Bob I am getting an error related to GetBooks there is an error showing that A namespace cannot directly contain members such as fields or methods

  • User profile image

    @BobTabor:Excellent tutorial. Easy to understand. Thanks Bob!.

  • User profile image

    would you please post a video on datagrid (mytoolkit) with chekbox select all in UWP xamarin and thanks for the tutorials :)

Add Your 2 Cents