Different Templates for Items with DataTemplateSelectors in Xamarin.Forms

  Рет қаралды 6,967

Gerald Versluis

Gerald Versluis

Күн бұрын

Пікірлер: 37
@petervestifrendrup1307
@petervestifrendrup1307 3 жыл бұрын
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!
@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!
@_samirdahal
@_samirdahal 4 жыл бұрын
I will call that, Conditional rendering 😎. Thank you for sharing Gerlad! 🎉
@jfversluis
@jfversluis 4 жыл бұрын
Haha yeah that’s a good name! Glad you liked it!
@СергейКошельник-н9н
@СергейКошельник-н9н 2 жыл бұрын
Great job!
@jfversluis
@jfversluis 2 жыл бұрын
Thank you!
@AMIRKHAN-dm2fm
@AMIRKHAN-dm2fm 4 жыл бұрын
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 4 жыл бұрын
I'm assuming you are using that inside of a DataTemplate?
@AMIRKHAN-dm2fm
@AMIRKHAN-dm2fm 4 жыл бұрын
@@jfversluis yes sir . is there any solution to achieve that.
@wmernissi2830
@wmernissi2830 2 жыл бұрын
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 ?
@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?
@Ajaxbreaker
@Ajaxbreaker 4 жыл бұрын
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 4 жыл бұрын
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
@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
@alexanderspiegel6747
@alexanderspiegel6747 3 жыл бұрын
The video and background color are nice :-)
@jfversluis
@jfversluis 3 жыл бұрын
Thanks Alexander! 😃
@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
@aiyaar3588
@aiyaar3588 4 жыл бұрын
Lol, how do you read my mind, Another great! video from you Gerald, I wish I could have 1000 accounts on KZbin and you will get subscription from all of them! :) Awesome!
@jfversluis
@jfversluis 4 жыл бұрын
Maybe someone gave me a little hint to make this... thank you Omar!
@alikarimi01
@alikarimi01 4 жыл бұрын
If it is possible for you , please create a video for binding
@jfversluis
@jfversluis 4 жыл бұрын
What do you want to learn about binding?
@alikarimi01
@alikarimi01 4 жыл бұрын
@@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 жыл бұрын
Here are a couple of videos on data binding: kzbin.info/aero/PLfbOp004UaYWOuVUuEtGlpkDIC1houhn_ Does that help? :)
@jfversluis
@jfversluis 3 жыл бұрын
@@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: kzbin.info/aero/PLfbOp004UaYWOuVUuEtGlpkDIC1houhn_
@AMIRKHAN-dm2fm
@AMIRKHAN-dm2fm 4 жыл бұрын
Great
@jfversluis
@jfversluis 4 жыл бұрын
You couldn't have even seen it so fast! :D
Decoupled Code with MessagingCenter in Xamarin.Forms
18:46
Gerald Versluis
Рет қаралды 12 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Xamarin Forms ListView Customization using DataTemplateSelector
16:12
sekhar srinivas
Рет қаралды 15 М.
Xamarin.Forms ListView vs. CollectionView - Which to use and why!
20:14
James Montemagno
Рет қаралды 31 М.
Create Custom Controls using BindableProperty for Xamarin.Forms
17:48
Gerald Versluis
Рет қаралды 16 М.
The Biggest React Framework You've Never Heard of
20:29
Theo - t3․gg
Рет қаралды 48 М.
Awesome Scroll Effects in Xamarin.Forms
14:03
David Ortinau
Рет қаралды 12 М.
Xamarin.Forms ListView - Everything you need to know (& .NET MAUI)
36:49
James Montemagno
Рет қаралды 63 М.
Turn any Event into a Command in Xamarin.Forms (MVVM All The Things)
14:44
Style Control States with Visual State Manager in Xamarin.Forms
19:19
Gerald Versluis
Рет қаралды 4,4 М.