Styling Xamarin.Forms Apps with Reusable Resources & Styles

  Рет қаралды 15,960

James Montemagno

James Montemagno

Күн бұрын

Пікірлер: 46
@truedaystar
@truedaystar 11 ай бұрын
Thanks for the video! Very useful to me learning to program using Xamarin.
@harag9
@harag9 2 жыл бұрын
Great video, just trying to learn MAUI and watching some random images that pop up that YT recommends, but all interesting. One question -- Width/Height Requests. I see you put numbers like 30, 50, 150 etc. but what exactly is this number - I'm so use to working in pixels it doesn't make sense to me as the displays for different devices are all different. Is there a general size I should work to?
@olby_band
@olby_band 3 жыл бұрын
Thanks for this video. How about dynamic resources and dynamic theme change?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
Next week :)
@imtiyazAhmad-gb7tn
@imtiyazAhmad-gb7tn 3 жыл бұрын
its always great to watch your tutorial thanks for share it with us. Also one request how we implement correct way "Kiosk mode" in Xamarin it will great support
@trevorkobilo2480
@trevorkobilo2480 3 жыл бұрын
Great refresher! Thanks.
@camilovega4914
@camilovega4914 3 жыл бұрын
Great explanation! Have you considered making a video about C#?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
We have so many good ones out there already channel9.msdn.com/Series/CSharp-Fundamentals-for-Absolute-Beginners and also dot.net/videos ;)
@Jad.abouzaki
@Jad.abouzaki 3 жыл бұрын
Thank you
@belmiris1371
@belmiris1371 3 жыл бұрын
Thanks for another great video. I think I may need a new computer. I had to turn off Hot Reload because it was hammering on my CPU even when I wasn't using the emulator.
@wacm
@wacm 3 жыл бұрын
Great video as always... Thank you for this. Is there a way we can move all the styles to a different file? For example a file called "styles.xaml" and keep all the styles there?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
Yup, take a look at merged dictionaries -> docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/resource-dictionaries#merged-resource-dictionaries
@steffi2128
@steffi2128 3 жыл бұрын
I would like to create a Dark Mode toggle!
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
Coming soon in a video :)
@smiel7777
@smiel7777 3 жыл бұрын
Hi James. I've converted one of my larger projects to use Styles. With regards to performance, Is there a recommended limit to how many items one can add to the app.xaml resource dictionary ? I've added a lot of styles and noticed that the IntelliSense are no longer picking up the keys when trying to add a static resource, so now I have to go back each time and double check which style I want to use. This raised the concern that a large resource dictionary might impact performance ?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
I haven't had any issues at all to be honest. General guidance is if you are using across multiple pages then put in app, else put it local in the page for stuff specific on that page.
@VEOdev
@VEOdev 2 жыл бұрын
I wanna know how can I reference the style from the C# code ? like if I have cards that I can generate in code and i want to assign that style to it how would i ?
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
See the documentation -> docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/styles/xaml/style-class
@samt1905
@samt1905 3 жыл бұрын
Hey James thanks, can you explain grid row definitions (simplified) with on platform from application resources?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
You could do like ColumnDefinitions="{OnIdiom Phone='Auto,*,Auto', Default='.05*,.9*,.05*'}"
@Otonium
@Otonium 2 жыл бұрын
x=Crystal clear Thank you!
@denisbmonteiro
@denisbmonteiro 3 жыл бұрын
I always used it when working with WPF, it's a nice feature to reuse styles. Could you explain how the device theme works with Xamarin controls? One time I tried to implement a light/dark theme but the controls keep changing colors when the device theme changed. I mean, how can we style an Entry for example to be independent from the device theme? Anyway, thanks for the great content!
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
Yup, video is coming on its way next week.
@cristisandu678
@cristisandu678 3 жыл бұрын
Quick question. How you recommend to make dark mode, using styles and with a switch to change all styles or another method?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
That video is coming this week!
@zx-xn1lb
@zx-xn1lb 3 жыл бұрын
I wish I could see this video sooner
@RenegadeVile
@RenegadeVile 3 жыл бұрын
This is a great overview. Though I have a fairly specific question. I'm currently creating sort of a styles library that contains various common styles that I use across multiple apps. Separate from them, I have a variables.xaml file that contains things like the colors I use, or values for height/width, etc. Is it possible to import the styles from an external library, BUT create a new variables resource dictionary and use the colors there instead? In other words, the styles I import from that library will use the colors I define in my app, not the 'default' ones in the library. I've gotten this to work up to a point. The styles import and I can see them, but they are unable to find any other static resources. The end goal is to have a large collection of reusable styles but in an individual app, I can still change the actual colors being used. I know I can just copy all the resource dictionaries over into my app and then make changes there, but that kind of beats the point, I feel.
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
I believe you could inherit from the base like i showed... but i haven't tried that. I have to assume that is possible
@RenegadeVile
@RenegadeVile 3 жыл бұрын
@@JamesMontemagno That would work, but then I would be redefining the styles all over again, just with a few different values set. And as far as I know, I cannot inherit from, for example, or .
@loladeking
@loladeking 3 жыл бұрын
It's almost impossible to use resources in code behind. All hits on stack overflow or xamarin blogs are all searching for answers
@anandshindey
@anandshindey 3 жыл бұрын
?
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
Everything is documented well on how to write and access them in c# docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/styles/xaml/style-class
@sjorsmiltenburg
@sjorsmiltenburg 3 жыл бұрын
var style = new Style(typeof(PancakeView)); style.Setters.Add(new Setter { Property = PancakeView.BorderColorProperty, Value = Color.FromHex(Application.Current.Resources["LightColor"].ToString()) });
@sjorsmiltenburg
@sjorsmiltenburg 3 жыл бұрын
woops, my code sample does not work (on uwp)... (maybe that's what you mean??)
@sjorsmiltenburg
@sjorsmiltenburg 3 жыл бұрын
this does work: TextColor = (Color)Application.Current.Resources["LightColor"];
@drivetrainerYT
@drivetrainerYT 2 жыл бұрын
Here’s my lots of thanks (+ YT tax)
@eddienoureddine7408
@eddienoureddine7408 3 жыл бұрын
Big thumbs up
@khaliphathiane584
@khaliphathiane584 3 жыл бұрын
The downside of adding reusable style in app.xaml is slow the application start up.
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
I have never had any issues with that at all to be honest. Apps are ahead of time compiled and parsed quickly. Like I said though you can put page specific styles in the pages.
@khaliphathiane584
@khaliphathiane584 3 жыл бұрын
I understand it’s doable but not the best practices, issue is another word. I just mean wish could have reusable components like Flutter or an approche like Blazor
@JamesMontemagno
@JamesMontemagno 3 жыл бұрын
@@khaliphathiane584 Could easily setup control templates, which are reusable components -> docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/templates/control-template
@khaliphathiane584
@khaliphathiane584 3 жыл бұрын
Thank will have a look
@RallySystem
@RallySystem 3 жыл бұрын
the next one should be animations and used svg and not img
@williamprogramer4168
@williamprogramer4168 3 жыл бұрын
⭐⭐⭐⭐⭐
@NightKingMarhoom
@NightKingMarhoom 3 жыл бұрын
You should open a university u know
@nicholasma5695
@nicholasma5695 3 жыл бұрын
too many ADs 😂
Dynamic App Themes in Xamarin.Forms - Light, Dark, & Custom Modes
25:13
James Montemagno
Рет қаралды 20 М.
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
Непосредственно Каха: сумка
0:53
К-Media
Рет қаралды 12 МЛН
The Biggest React Framework You've Never Heard of
20:29
Theo - t3․gg
Рет қаралды 51 М.
How to Learn to Code FAST (Do This or Keep Struggling)
11:00
Andy Sterkowitz
Рет қаралды 726 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 360 М.
Custom Fonts & Font Icons/Images in Xamarin.Forms
20:18
James Montemagno
Рет қаралды 23 М.
Preparing a Xamarin.Forms Shell App for Development
11:28
James Montemagno
Рет қаралды 34 М.
Xamarin.Forms ListView vs. CollectionView - Which to use and why!
20:14
James Montemagno
Рет қаралды 31 М.
The Latest Celebrity Tech Scam…
19:21
Linus Tech Tips
Рет қаралды 2,5 МЛН
This is the Only Right Way to Write React clean-code - SOLID
18:23
The Secret Science of Perfect Spacing
9:40
Chainlift
Рет қаралды 479 М.
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН