UWP-042 - Utilizing User Controls as Data Templates

Play UWP-042 - Utilizing User Controls as Data Templates
Sign in to queue

The Discussion

  • User profile image

    sorry. lost me.

  • User profile image

    I am kinda lost to.

  • User profile image

    As in UWP-040 if you try to reproduce this into you own project by copy pasting some code,

    begin creating the classes in the Models namespace and build the project before pasting in code that refers to them.

    In the case of this little app the code inside of the NewContactButton_Click method refers to the Icon class. But also in the MainPage.xaml the Icon and Contact classes are referred too. Comment them out and build your project.

  • User profile image


  • User profile image

    Thanks Bob...this was driving me crazy on a small project I'm working on.(first adaptive UI) Worked first time - cut and paste. Love it.

  • User profile image

    Hi Bob,

       Thanks for your great work ! I have a question that , why in the constructor of ContactTemplate,

    this code  this.DataContextChanged += (s, e) => Bindings.Update(); must be used ,I'm new to use x:bind

  • User profile image

    Umm... I don't know if I've done anything wrond, but the gridview shows a grid of "ProjectName.Models.Contact". Any ideas about how to fix this?

    Thanks in advance. 

  • User profile image

    @Srikanth20:Oops, my bad. I didn't surround the <local:template/> tag with the data and item template tags.

  • User profile image

    I am not sure this makes a lot of sense... at least not to me. Reason is - what if you have several embedded user controls?? You need to duplicate the Visual State groups in each user control?? Or is it a workaround for something that normally should work at the page level?

  • User profile image

    Thanks Bob Good job

  • User profile image
    Rishabh Kumar

    I think in this lesson you should have taken more time to elaborate the concepts.
    This lesson is the only one i needed to watch more than twice in this whole series so far.

  • User profile image

    This lesson is really useful but the concept are explaned too fast and. More deep explaination on what you are doing would have been really useful.

  • User profile image

    I try to use this statement
    this.DataContextChanged += (s, e) => Bindings.Update();
    but system say the name 'Bindings' is not exist current context, how to solve this?

  • User profile image

    @rajmurugan: this.Bindings is generated by the Visual Studio XAML designer only when your XAML page contains compiled data bindings using x:Bind

  • User profile image
    Hello. I tried this today, April 10, 2019, and this doesn't seem to be working anymore. I copied this example and when I run it, I get and error:
    UnhandledException += (sender, e) => {
    if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();

    Did something change? What is the best way to do this today?
  • User profile image
    Jon Steiner


    This is still the correct way to deal with this error, however, you can't debug with it.

    If you change it from Debug --> Release you will realize the bug is no longer present.

Add Your 2 Cents