DataContext in Xamarin And WPF #99
Replies: 5 comments
-
If you set the x:DataType on the Page to your ViewModel, it currently gives you Intellisense and many more! Take a look at Compiled bindings - https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings |
Beta Was this translation helpful? Give feedback.
-
yea that's right. |
Beta Was this translation helpful? Give feedback.
-
@KurdCsharper I faced the same dilemma when I started out in Xamarin 4 years ago. Then I just accepted the fact that things were different between WPF and Xamarin, but I asked the same question back then only to realize my opinion meant nothing. Now when I start to write WPF, I start writing XAML like it's Xamarin, I find out it doesn't build, and I have to teach myself WPF all over again. lol Don't worry. Xamarin is changing into MAUI. 2 years from now, it will be something else. Maybe we'll write mobile apps in HTML and not XAML. The only thing permanent is change in the world of technology. |
Beta Was this translation helpful? Give feedback.
-
Yea but I like Xaml. and I hope they use the same XAML as WPF. |
Beta Was this translation helpful? Give feedback.
-
Hi @KurdCsharper , you and many other people want, you can bring your support here #43 |
Beta Was this translation helpful? Give feedback.
-
Summary
We can use Window.DataContext in WPF to specify the ViewModel.
as a friend mentioned in a comment, Xamarin has this feature too, but with a different syntax.
I'm WPF Developer and I think it's not a good idea to have two syntaxes for XAML.
API Changes
This is how it works in WPF.
<Window.DataContext> <vm:PurchasePaymentViewModel x:Name="viewModel" /> </Window.DataContext>
And the Same Property for Xamarin with Different Syntax
<Window.BindingContext> <vm:PurchasePaymentViewModel x:Name="viewModel" /> </Window.BindingContext>
I'm WPF developer and the first time I code Xamarin, I said home sweet home, Xaml Again 💯
But there are some differences and I don't know why
Beta Was this translation helpful? Give feedback.
All reactions