C# WPF Tutorial #21 - Styles and ControlTemplates

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

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

  • @WIckedOmenOfThunder
    @WIckedOmenOfThunder ปีที่แล้ว +8

    Omg i had the hover issue last week and spend ages trying to find a clear explanation for why some examples work and other didn't. Thanks for the video!

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

      Haha! I know that feeling. Glad it helped!

  • @wookyumkim4669
    @wookyumkim4669 ปีที่แล้ว +7

    As always, your video is awesome! I'm again amazed by your proficiency on C# WPF. Thank you very much for making this series 😊😊

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

      Thank you for the kind words, glad it is helpful!

  • @kuzelk6571
    @kuzelk6571 11 หลายเดือนก่อน +2

    Thanks a lot for this tutorial!! I tried a few times the MSFT own text tutorials, but for me it was too difficult to understand it in the deep. Here i understood 3 important things within a minute! 🙂

    • @KampaPlays
      @KampaPlays  11 หลายเดือนก่อน

      Thanks, glad to help!!!

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

    Thank you for providing the videos.
    It is useful to me as a WPF beginner.

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

      Very glad it is helpful!

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

    Eagerly waiting for your next video

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

      Thank you, I'm a bit behind because of work but I should have the 1st MVVM video out Monday or Tuesday!

  • @sem_the_man
    @sem_the_man 8 หลายเดือนก่อน

    thank you so much, learned a lot and never knew you could just take the default style like that!

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

    thank you... love all these tips... just brilliant.

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

    Keep up the amazing work

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

      Thanks so much!!

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

    Thank you very much for this awesome Series!

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

    It's very useful video! Thank you for your work!❤

  • @codyaimes4354
    @codyaimes4354 2 หลายเดือนก่อน

    DUDE!!! Great vid and thanks!

  • @kovcorporation
    @kovcorporation 3 หลายเดือนก่อน

    very simple and usefull describe for a complicated stuff :) thanks

  • @ErcanMutlu-r4x
    @ErcanMutlu-r4x 6 หลายเดือนก่อน +2

    IT WORKS ON new version. You dont have to REDEFINE content template

  • @thomasaminer
    @thomasaminer 6 หลายเดือนก่อน

    Thank you, a highly useful video!

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

    Great tutorial man! Just one question, is there any way to like create a resource file somewhere and just import them to your current window, and it will then auto override all the controls? I just kinda find them a bit annoying clucking on the top of the project file.

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

      Thanks!
      I think what you are looking for is creating and including resource dictionaries. You can keep all of your styles (explicit and global) in separate files and then merge those dictionaries into your App.xaml and use the styles across your entire project. (or you could do a specific window/usercontrol)
      I have a bit about doing it here:
      th-cam.com/video/F7DiRnH6Yqo/w-d-xo.html
      and here's a link to a text example:
      learn.microsoft.com/en-us/windows/apps/design/style/xaml-resource-dictionary#merged-resource-dictionaries

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

      @@KampaPlays Thank you so much for the answer! I have one more question: based on your tutorial series, say I have a usercontrol that has a textbox and button. I then call the usercontrol multiple time on my main window just like in the tutorial (eg last name texbox, first name textbox). Each button when pressed, should save their textbox's value on a string on the main window. How can I achieve something like this? Thank you!

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

      In that case you will need a way for your mainWindow to know that the button has been clicked. You *could* pass your mainWindow to your usercontrols, and use it to call some method in mainWindow when your button is pressed. A better (less-coupling) way to do it would be to create an event in your user control that you invoke on button click, and when your controls are created in mainwindow, subscribe to these events. Events are a bit more advanced of a C# topic, but they are extremely useful, and I recommend looking into them!
      learn.microsoft.com/en-us/dotnet/standard/events/
      (Check the code under the "Events" and "Event Handlers" sections for examples of what I'm talking about)

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

      @@KampaPlays Do you have any video tutorials for this?

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

      Not yet, it's on my list for the more intermediate/advanced Playlist i want to do next.

  • @milentiusgaming
    @milentiusgaming ปีที่แล้ว +4

    when i select "convert to new resource" i see the dialog popup, i fill it out and select ok and it puts in the basic stuff with nothing else, no "button.mouseover.background" or anything else, just the normal background color, would that be because i already have a "buttonstyle.xaml" defined from watching your previous video where you taught us about the resource dictionary?
    UPDATE: Yes it was lol, i just removed the original style from the resource dictionary and tried again and it added all the extra template stuff.

    • @KampaPlays
      @KampaPlays  ปีที่แล้ว +4

      Good catch, and good problem solving!! I didn't think to mention this, but I bet this comment will help someone else!

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

      Worked for me as well, thanks!

    • @jeny.biju.
      @jeny.biju. 5 หลายเดือนก่อน +1

      This helped me too! Thanks.

  • @jhlfergus
    @jhlfergus 4 หลายเดือนก่อน +1

    I have a custom app that I am creating and I am using custom UI textures so it doesn’t look like the standard app at all. In that app I am using treeview and I want to change the look of the scroll bar to match the rest of the app. How can I do that?

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

    Hello Krampa, thanks a lot for the courses they are great no matter the fact the I work in C# around 2 years and that I know most of the stuff, I still just enjoy listening and watching your courses from the beginning :D Truth to be told I still find quite difficult to understand how the progress bar is working. I don’t mean like normal value that is changing just by adding ++ I mean by using BackgroundWorker class. Can you please make a video and try to explain who should we use PB during async scenarios and how to guess how long the process will take? Thank you very much.

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

      Thanks so much!
      Great suggestion. The progress bar is one of the trickiest controls when you throw in multithreading, because its not very intuitive on how it's supposed to be used. I will add this to my list of todos!!

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

    Thank you very much for this playlist
    Please make MVVM CRUD EF and Dependency injection small application
    Great Explanation

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

      Thank you! I will add these to my list. I'm working on MVVM now!

  • @bogdanlazar3278
    @bogdanlazar3278 9 หลายเดือนก่อน +1

    Thank you :) This is nice :D

    • @KampaPlays
      @KampaPlays  9 หลายเดือนก่อน

      Thank you !!

  • @Stars.Stripes.andVan
    @Stars.Stripes.andVan ปีที่แล้ว +1

    I didn’t know we can create a template by clicking on the properties’ style! It would be great if you can make a video of custom listview. Just saying.haha. Thanks for the video! 😆

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

      Glad to help! Will add it to the list!

  • @IonCasu-fw3ro
    @IonCasu-fw3ro 10 หลายเดือนก่อน

    Why at 4:50 the target type magically become "{x:Type Button}" from "Button"?

    • @KampaPlays
      @KampaPlays  9 หลายเดือนก่อน

      That is an excellent question. I'm honestly not sure at this point what I did there. Sorry for the confusion.

  • @朱亚君-m9b
    @朱亚君-m9b ปีที่แล้ว +1

    Wonderful

  • @thomasg2016
    @thomasg2016 3 หลายเดือนก่อน

    Hey, thanks for the great tutorials! I hate having to ask for help, but when I try "Convert to New Resource" for the button style, that option is grayed out. I'm using VS 2017 pro edition. Do you know if that isn't available in the version I'm using or if there's something else that would make it unavailable? Thanks.

  • @yumecapybara
    @yumecapybara 2 หลายเดือนก่อน

    Sorry may i ask this:
    I had set :
    ,
    why when I changed :
    ,
    it wouldn't make other button also change it to blue but only the button that i had set style="{ StaticResource button9}"?
    Isn''t the SolidColorBrush also a Global style?

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

    awesome💓

  • @marcellodichiera
    @marcellodichiera 2 หลายเดือนก่อน

    Hi, is there a way I can contact you? I am really going crazy to change the mouseover property of a combobox. Let me know thanks a lot, your tutorials are really helpful

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

    thanks a lot

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

    Excellent video, but how does one remember this wide range of WPF material when working on a big project?

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

      Thanks! It comes with time and repetition, just like anything. I can recall a large portion of .NET and WPF from memory, but I still check the documentation regularly for things that I don't use often.
      One piece of advice I give is to write it out as often as you can instead of copy/paste, and you will be able to remember/understand it better. Typing/entry speed is insignificant compared to the time it takes to properly solve the problem!

  • @n1mi-
    @n1mi- ปีที่แล้ว +1

    thx, man

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

      welcome! glad to help.

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

    How would you bind some Property to a Trigger Value?
    Love your Videos!

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

      Thanks!
      I don't think I have anything on this specifically yet, but you can use "DataTrigger" to use bindings to regularly defined properties. Check out the "DataTrigger" section here, it might help out:
      wpf-tutorial.com/styles/trigger-datatrigger-event-trigger/

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

    When I added The "Control Template" it shrinks the buttons down to nothing and I have stretch them out. Why is this? The buttons height and width are not set, but I don't need them to be.

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

      When you override the default control template with a blank template it loses all of its standard formatting. What you are describing may be a missing Horizontal/Vertical Alignment of "Stretch". Let me know if this isn't what you meant.

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

    Hey :)
    First of all, thanks for this tutorial series. I´m just learning WPF and this is by far the best explanations i´ve seen.
    One question tho.
    Is there a posibility, to group items into a Grid Row/Column?
    So instead of saying:
    it would sometimes be easier to just say
    Do you know, if this is possible?
    Thanks :)

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

      Thank you, and definitely! You can put the objects into a parent container of some sort and set that parent's column/row. Grid is quick and easy but sometimes you may want a StackPanel/ScrollViewer/something else specific for your controls to live in.

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

      @@KampaPlays Thanks :) Didn´t read your answer until now, but i found it out by myselfe. I just had to create a new grid, put it in the row/column i want and put everything in that grid. Instead of just typing like i wrote.. Thanks :)

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

    Sir hopefully you build project have database.

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

      I will add database integration to the to-do list! Thanks!

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

    How do I put the style template in a separate file and how do I use it then?

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

      The previous video #20 (th-cam.com/video/F7DiRnH6Yqo/w-d-xo.html) shows how to make the style reusable both explicitly and application wide. Hope this helps!

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

      thanks a lot@@KampaPlays

  • @testg4andmmm129
    @testg4andmmm129 4 หลายเดือนก่อน

    12:15 xamllll heelllllllll ,,,,,,, definitely different file ...with proper name......

  • @blatopebas
    @blatopebas 2 หลายเดือนก่อน +1

    Thanks a lot