Different Templates for Items with DataTemplateSelectors in Xamarin.Forms

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024

ความคิดเห็น • 37

  • @petervestifrendrup1307
    @petervestifrendrup1307 3 ปีที่แล้ว +1

    Thanks a lot for this. Exactly what I needed! Been struggling with this problem for a while!

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Awesome! Glad I could help you out!

  • @joehanna_
    @joehanna_ ปีที่แล้ว

    Thanks for another great video - you are doing an awesome job here for the Xamarin platform. For future videos, please choose names a little more carefully. I understand you said that the DataTemplate x:Key didn't have to match anything else, but it does in fact match properties used in the SubscribeDataTemplateSelector class. Coming in new to this and trying to review the code and glue it all together, this becomes confusing very quickly.
    Still worthy of ⭐⭐⭐⭐⭐Thank you so much!

  • @СергейКошельник-н9н
    @СергейКошельник-н9н ปีที่แล้ว

    Great job!

  • @_samirdahal
    @_samirdahal 3 ปีที่แล้ว

    I will call that, Conditional rendering 😎. Thank you for sharing Gerlad! 🎉

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      Haha yeah that’s a good name! Glad you liked it!

  • @aiyaar3588
    @aiyaar3588 3 ปีที่แล้ว +1

    Lol, how do you read my mind, Another great! video from you Gerald, I wish I could have 1000 accounts on TH-cam and you will get subscription from all of them! :) Awesome!

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      Maybe someone gave me a little hint to make this... thank you Omar!

  • @alexanderspiegel6747
    @alexanderspiegel6747 3 ปีที่แล้ว

    The video and background color are nice :-)

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Thanks Alexander! 😃

  • @wmernissi2830
    @wmernissi2830 ปีที่แล้ว

    Helo Gerald. I am using .NET MAUI. I am trying to set the data template of a collection view in a custom control through the usage of a bindable property in the custom control. The bindable property of the custom control is set from the MainPage using XAML code and it contains a ContentView with a Grid which, in turn, has labels. When I set the item template of the collection view inside the custom control when the there is a property change, the collection view will not work. Any ideas ?

  • @TBTH2H
    @TBTH2H 2 ปีที่แล้ว

    Hi Gerald, thanks a lot for this great video, which is really helpful! I assume, the same approach can be used in .Net Maui, correct? And I have another question: How can I extend that for handle selected items also? Do I have to extend the logic for a third entry? What I want to do is to use alternating row-styles in a kind of datagrid-control. Best regards: Thomas

  • @Ajaxbreaker
    @Ajaxbreaker 3 ปีที่แล้ว

    Awesome! I just spent two days banging my head against a wall trying to figure out why my data binding wasn't working and literally an hour after figuring it out I saw this video which is probably the clearest demo I've seen of it and you weren't even covering the subject :D. Real question though: this works if you're just pulling info from a list of strings but it'd be really helpful to see an example of a more complex object. If I'm passing it an object with a name string property for instance and I try to access item.name my application starts throwing errors...

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Haha awesome! Well, I wish you’d seen the video before, but appreciate you letting me know and the kind words!
      Noted on the complex object. Let’s see if I can whip up a video about that... what are the errors you’re seeing?

    • @michaelfelleisen6424
      @michaelfelleisen6424 3 ปีที่แล้ว

      Frist you have to tell your DataTemplate from which class you want to bind properties. For me it was a class in my "Models" folder so I added an include for my like this:
      xmlns:models="clr-namespace:[YourProjectName].Models"
      and after that you can tell your which DataType to use like this:
      now you could bind something from your class inside the

  • @AMIRKHAN-dm2fm
    @AMIRKHAN-dm2fm 3 ปีที่แล้ว +1

    i have a question .
    i am using collection view in one of my project.in collection view i am using lable and using x:Name=lblName property
    but this lblName .. i cant access in my .cs file why?and the other side any other lable outside the collection view i can access.
    Thanks

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      I'm assuming you are using that inside of a DataTemplate?

    • @AMIRKHAN-dm2fm
      @AMIRKHAN-dm2fm 3 ปีที่แล้ว

      @@jfversluis yes sir . is there any solution to achieve that.

  • @EdRawrDev5813
    @EdRawrDev5813 2 ปีที่แล้ว

    Hi I got a Specified cast is not valid. following the tutorial any idea?
    I tried same steps.

    • @jfversluis
      @jfversluis  2 ปีที่แล้ว

      Did you pull down the sample code from the repo and try that?

  • @boysen01
    @boysen01 3 ปีที่แล้ว

    Thanks for sharing Gerald, this is great. Any chance you know what the C# equivalent statements to the XAML at 12:00 would look like?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Absolutely! Described in our wonderful Docs: docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/templates/data-templates/selector#consuming-a-datatemplateselector-in-c

    • @boysen01
      @boysen01 3 ปีที่แล้ว

      @@jfversluis Very nice example, thanks! It is great that most of these examples show the C# equivalent code

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      @@boysen01 the docs are pretty good that way!

  • @alikarimi01
    @alikarimi01 3 ปีที่แล้ว +1

    If it is possible for you , please create a video for binding

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      What do you want to learn about binding?

    • @alikarimi01
      @alikarimi01 3 ปีที่แล้ว

      @@jfversluis I have a data grid with 5 columns , in the columns there are some numbers are negative. I want to set their number and textColor with binding

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +2

      Here are a couple of videos on data binding: th-cam.com/play/PLfbOp004UaYWOuVUuEtGlpkDIC1houhn_.html
      Does that help? :)

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      @@codigoadictivo let me know what is unclear after that

  • @davidmorrow1393
    @davidmorrow1393 2 ปีที่แล้ว

    How do you access Label's or Entry's from DataTemplateSelector? Like access Label on SubscribeTemplate? tried x:Name="SelectorLabel" with no Intellisense.

    • @jfversluis
      @jfversluis  2 ปีที่แล้ว

      Since it’s a template that will be applied to each entry it’s impossible to work with x:Name. Each instance would have the exact same name. You will have to use data-binding. Have a look here: th-cam.com/play/PLfbOp004UaYWOuVUuEtGlpkDIC1houhn_.html

  • @yeahscienceman
    @yeahscienceman 3 ปีที่แล้ว

    How can i set data template in accordance with CarrouselView.Position? Like if it is 0 - OneTemplate, 1 - SecondTemplate...
    P.S: i did make a reference to the CarouselView in the selector class, but it does not change the position value from 0

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Hm is there another way to do that? Technically you could determine in what position the item is, but not sure if that is something you would want to do

    • @yeahscienceman
      @yeahscienceman 3 ปีที่แล้ว

      @@jfversluis managed to succeed it by using ControlTemplate

  • @AMIRKHAN-dm2fm
    @AMIRKHAN-dm2fm 3 ปีที่แล้ว

    Great

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      You couldn't have even seen it so fast! :D