How to use IDataErrorInfo to validate a WPF Model in C#

Поделиться
HTML-код
  • Опубликовано: 30 янв 2025

Комментарии • 53

  • @stevenpike3176
    @stevenpike3176 9 лет назад +2

    Thank you. Your clear speech and direct manner facilitated my learning style. I can't believe it's so hard to find a "from scratch", bottom-up tutorials for MVVM / WPF like your tutorials. I really appreciate you sharing your knowledge.

  • @2wheels4Mo
    @2wheels4Mo 11 лет назад

    Hi,
    I recently started with WPF / MVVM and C# and your videos show me how to deal with this stuff in a proper way! Sometimes it's a bit fast for a beginner but it's ok :)
    Thank you for your effort
    *2 thumbs up*

  • @sudipkarmakar8565
    @sudipkarmakar8565 11 лет назад +12

    Nice series of videos . Could you also share projects having separate Model , View and ViewModel projects alongwith real Database interaction (SQLExpress !) with EF framework .

  • @anthonypetiot8816
    @anthonypetiot8816 10 лет назад

    Great video !!!!
    Simple, straight to the point, love it !

  • @ooikaiyang9254
    @ooikaiyang9254 5 лет назад

    Nice video ! Hope can see more about MVVM Tutorial !!

  • @thegeox87
    @thegeox87 11 лет назад

    Great serie of videos David, really appreciate it

  • @arunatripathi6353
    @arunatripathi6353 11 лет назад

    Hi I like this session. As IDataErrorInfo is very useful.

  • @NirreFirre
    @NirreFirre 11 лет назад

    Very clear and helpful, please keep it up and perhaps add in a part on how to handle disconnected models (WCF or other SOA as the interface for the clients). I'm just wrapi

  • @NirreFirre
    @NirreFirre 11 лет назад

    ..wrapping my head around the Repository and Unit of Work patterns and ds youruploads great.

  • @DX7Dev
    @DX7Dev  11 лет назад +1

    Thanks so much! More to come as long as there is a demand for these videos. :)

  • @bhargavikotha3936
    @bhargavikotha3936 11 лет назад

    Hi David I like all MVVM session.

  • @pavelcermak1010
    @pavelcermak1010 10 лет назад +1

    Thanks for the great tutorials, this is great job which helped me a lot. Keep going :)

  • @sanjaythorat8521
    @sanjaythorat8521 11 лет назад

    Hi David there is always demand for WPF videos because I personally found that on web there is very less and appropriate study materials, my only concern is that while showing demo the visibility of your visual studio is not clear I mean small font and you may skip other unwanted windows so that your visual studio will look big in size while recording a video.
    Thanks and great work.

  • @DX7Dev
    @DX7Dev  11 лет назад

    I'm not sure I follow your question. I don't recall (checked the video too) using resource files in this screencast. But! I digress. Storing localizable strings in a resource file is actually recommended. Resx files are portable and you can change an executable's resources without having to recompile it, which makes it easy for teams to do localization/globalization of strings for different languages.

  • @cnichoyt
    @cnichoyt 11 лет назад

    Hi David,
    I enjoyed these videos. Nice and clear.
    Any plans to expand on the series?
    I'd be interested in an items collection with an item's property editor implemented by a user control, demonstrating data binding and multiple view models (items collection has one and editor has another). I hope that's general and interesting enough to tempt you?

  • @MrSubfeed
    @MrSubfeed 9 лет назад +4

    Honestly this is alot different than mvc web apps. I was so confused until i saw these videos

  • @DX7Dev
    @DX7Dev  11 лет назад +1

    Of course. However, I often go without it to force myself to memorize type names in the BCL.

  • @zeevarad
    @zeevarad 11 лет назад

    Hi David,
    Thanks for these videos - really "easy on the ear " (if such idiom exists...)
    I will much appreciate a some what full example with database (EF5 maybe) and even maybe a Unity along the way. I know this is an MVVM series but it will nice to get a full idea of a real life application architecture.Any way thanks again

  • @DX7Dev
    @DX7Dev  11 лет назад

    In short, if your resource string is meant for display, I would expose it through the view-model, not the model. Or bind directly from the view, but that doesn't mean it's never okay to use resource strings in models. Resource strings have a wide-array of usages. Hope that helps.

  • @adootube88
    @adootube88 11 лет назад

    Thanks for the information, I was also thinking about doing that in the viewmodel

  • @DX7Dev
    @DX7Dev  11 лет назад

    A better approach would be to call your resource files from your view-model. Your view-model would wrap the model in this case as not to expose it to the view. When a view-model gets too big, you can break it up into smaller view-model's (remember that it's okay for a view-model to parent another view-model). The key to remember is that a view-model really represents your views state in a decoupled way, whereas the model is just data.

  • @adootube88
    @adootube88 11 лет назад

    Nice video! What would you do when you have an application in multiple languages? Any suggestions? Because I don't think it's appropriate to use the resource file to get the string in the model class? Or am i wrong here :)

  • @TheJespar
    @TheJespar 11 лет назад

    Hello, I found these videos very useful, thank you! But, there's still one thing that I'm wondering about: If I want to make a button for each property (in my case, I want an individual button for each property to randomize it), do I actually have to make a separate Command for each one, or is there some way to make the Command more dynamic so it can be used for all buttons? Or am I missing something obvious?

  • @Tlcunha81
    @Tlcunha81 10 лет назад

    Thanks alot for the tutorial. It is helping me a lot. I have a question though, What is the simplest way or the proper way to disable the validation when the textbox is disabled?

  • @LuisitoSalvarezza
    @LuisitoSalvarezza 11 лет назад

    Exelente los video, si no es molestia me gustaria que expliques como implementear IoC, abrazo desde Argentina.

  • @krimbelkacem5751
    @krimbelkacem5751 10 лет назад +1

    thank you very much but where is the session 04 you us you premessed for the editing an the deleting part
    thank you

    • @DX7Dev
      @DX7Dev  10 лет назад

      krim belkacem Its up now. Sorry for the wait.

  • @omarbousbia6916
    @omarbousbia6916 7 лет назад

    Good tutorial and great typing speed
    I have a simple question for you, I noticed that you're avoiding the usage of Intellisence, WHY??

  • @adootube88
    @adootube88 11 лет назад

    Yes I know that it is recommended, my question was a bit unclear :) but is it the correct way to call the string from the resource file in the model? Because I think that the model class doesn't have to know anything about the resource file, or am I wrong? Because otherwise you can't reuse that specific model class somewhere else instead of setting that specific string in the resource file... Hopefully I'm a bit clear here with my explanation :)

  • @DX7Dev
    @DX7Dev  11 лет назад

    Glad. CommandParameter is pretty useful for these scenarios.

  • @DX7Dev
    @DX7Dev  11 лет назад

    You could also bind to a collection of ICommand directly and display a button for it via a data template. ;)

  • @erik6048
    @erik6048 10 лет назад +2

    Is it in the spirit of MVVM to bind to a Model property, instead of a ViewModel Property?
    I thought the View is only connected to the ViewModel, and only through Binding.

    • @DX7Dev
      @DX7Dev  10 лет назад

      You can, but I advise against it and promote using a ViewModel or Façade pattern instead. It's not necessarily a wrong approach, but you get better separation of concerns not exposing the model directly and through experience you will learn that it is better not to.

  • @MauroSebastian1978
    @MauroSebastian1978 8 лет назад

    Great tutorial! I have one questions. What happen if you do not set the CustomerName when the window loads and you do not want to see the error message or red border? Is it possible? Thanks!

    • @groberti
      @groberti 8 лет назад

      you can do it easily with dirty checking

  • @DX7Dev
    @DX7Dev  11 лет назад

    Thanks for the feedback!

  • @michaelpuno3812
    @michaelpuno3812 10 лет назад +1

    How about if I want the textbox blank on first run?

  • @acapellalove6168
    @acapellalove6168 7 лет назад +1

    what's the code at the INotifyPropertyChanged members????

  • @taab84
    @taab84 5 лет назад

    a question about xaml styling with validation error messages, can we use classes like with css?

    • @DX7Dev
      @DX7Dev  5 лет назад

      Not to the same extent. You can reuse styles and have style inheritance but it's nowhere near as flexible.

  • @KlausAUsdemosten
    @KlausAUsdemosten 11 лет назад

    Have you heard about IntelliSense and it's autocomplete feature? ;)

  • @billsmock5410
    @billsmock5410 8 лет назад +1

    Man that keyboard loud as fuck! Thanks for good vid tho

  • @VongolaFamilie
    @VongolaFamilie 5 лет назад

    Thanks alot

  • @Eindrew9
    @Eindrew9 7 лет назад

    It does not work by me :( I have no error warnings in the code but when I test the validation, the Textbox does not become red and the Message does not appear under the text box.

  • @DX7Dev
    @DX7Dev  11 лет назад

    Thanks!

  • @Eindrew9
    @Eindrew9 7 лет назад

    I cant just write NotifyPropertyChanged("name"); it says I have to implement an extra Method. Is this correct? You don´t do that in your video.

  • @DX7Dev
    @DX7Dev  11 лет назад

    Agreed!

  • @amrgaber4662
    @amrgaber4662 6 лет назад

    Thanks

  • @alexkushner3959
    @alexkushner3959 5 лет назад

    Where is SaveChanges() called?

  • @acapellalove6168
    @acapellalove6168 7 лет назад

    can you post the codes? thank u!

  • @hoanglong5256
    @hoanglong5256 8 лет назад

    why you use
    string IDataErrorInfo.error{
    get{return null}
    }
    replace implement interface
    public string Error
    {
    //get { throw new NotImplementedException(); }
    get
    {
    return null;
    }
    }

  • @TheJespar
    @TheJespar 11 лет назад

    Never mind, I found the CommandParameter element..!

  • @DX7Dev
    @DX7Dev  11 лет назад

    Thanks for the feedback!