How to catch multiple validations with DataAnnotations MVVM?

I have a property I'm validating that has two dataAnnotations. I want to catch all the validation exceptions at once.
private string streetAddress1;
[Required(ErrorMessage = "test error")]
[StringLength(50, MinimumLength = 5)]
public string StreetAddress1
get { return streetAddress1; }
set
ValidationInterceptor(value);
streetAddress1 = value;
RaisePropertyChanged("StreetAddress1");
I can currently catch one at a time like so
public void ValidationInterceptor(object value, [CallerMemberName] string propertyName = "")
try
Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = propertyName });
catch (ValidationException e)
ValidationResult result = e.ValidationResult;
Thanks

Check out my sample
https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
That extracts all errors to a collection the view can use...
This bit does one property
public void ValidateProperty(string propertyName)
// If validating a property then there can be no conversion error
errors.Remove(propertyName);
var vContext = new ValidationContext(this, null, null);
vContext.MemberName = propertyName;
List<ValidationResult> vResults = new List<ValidationResult>();
Validator.TryValidateProperty(this.GetType().GetProperty(propertyName).GetValue(this, null), vContext, vResults);
TransformErrors(vResults);
FlattenErrorList();
NotifyErrorsChanged(propertyName);
private void TransformErrors(List<ValidationResult> results)
foreach (ValidationResult r in results)
foreach (string ppty in r.MemberNames)
AddError(ppty, r.ErrorMessage, ErrorSource.Validation);
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles

Similar Messages

  • How to Open multiple form with only one screen painter file

    Hi all ,
    I want to reopen the form without closing the active form ,i want to use same srf file ..
    I have already try it but form already exist error occur .
    pl help me , how to do it ?
    how to open multiple form with same srf file without closing active forms .
    thanks in advance,
    msw

    <?xml version="1.0" encoding="utf-16" ?>
    <Application>
      <forms>
        <action type="add">
          <form appformnumber="-1" FormType="-1" type="0" BorderStyle="0" uid="BOE" title="Bill of Entry" visible="1" default_button="1" pane="0" color="0" left="365" top="62" width="801" height="410" client_width="785" client_height="372" AutoManaged="1" SupportedModes="15" ObjectType="">
            <datasources>
              <dbdatasources>
                <action type="add">            
                </action>
              </dbdatasources>
              <userdatasources>
                <action type="add"/>
              </userdatasources>
            </datasources>
            <Menus>
              <action type="enable">
                <Menu uid="1282"/>
              </action>
              <action type="disable">
                <Menu uid="5890"/>
              </action>
            </Menus>
            <items>
            </items>
            <ChooseFromListCollection>
              <action type="add">
                <ChooseFromList UniqueID="-1" ObjectType="-1" MultiSelection="0" IsSystem="1"/>          
              </action>
            </ChooseFromListCollection>
            <DataBrowser/>
            <Settings Enabled="0" MatrixUID="" EnableRowFormat="1"/>
          </form>
          <form appformnumber="-1" FormType="-1" type="0" BorderStyle="0" uid="BOE1" title="Bill of Entry" visible="1" default_button="1" pane="0" color="0" left="365" top="62" width="801" height="410" client_width="785" client_height="372" AutoManaged="1" SupportedModes="15" ObjectType="">
            <datasources>
              <dbdatasources>
                <action type="add">
                </action>
              </dbdatasources>
              <userdatasources>
                <action type="add"/>
              </userdatasources>
            </datasources>
            <Menus>
              <action type="enable">
                <Menu uid="1282"/>
              </action>
              <action type="disable">
                <Menu uid="5890"/>
              </action>
            </Menus>
            <items>
            </items>
            <ChooseFromListCollection>
              <action type="add">
                <ChooseFromList UniqueID="-1" ObjectType="-1" MultiSelection="0" IsSystem="1"/>
              </action>
            </ChooseFromListCollection>
            <DataBrowser/>
            <Settings Enabled="0" MatrixUID="" EnableRowFormat="1"/>
          </form>
        </action>
      </forms>
    </Application>

  • How to do file validation with ODI 10.1.3.5

    Hi Team,
    Please help me, how to handle file validation with ODI?
    My source is files.
    Requirement:
    With ODI i have to do the file validation and file data loading successfully. Once it is successfully done then i have to move the particular file and move to different directory.
    Any internal tool is there in ODI package to watch the file.
    Regards,
    Suresh

    Hi Suresh,
    You can do your file loading and validation in an ODI interface.
    Once you are done with the interface, add it to a package, you can set up subsequent steps in the package to move the file to another location using the built in ODI file utilities in the package.
    Terrence.

  • How to move multiple clips with transitions?

    Im still transitioning from FCP7 to FCP 10.1.2 and can't believe I have missed the lesson that explains how to move multiple clips with transitions.
    Up till now I have tried several work arounds including deleting all the transitions then using the (P) Position tool to move the clips from the primary track to some track above it then re adding all the transitions.  This is a function I do on a daily basis.  Am I missing something?  Please help!
    Thank you

    With some further investigation, the transitions have nothing to do with my problem.  In my case there was a tiny “Black gap slug” within the group that was preventing me from being able set it on top of another group of clips or gap someplace.  But even with the gap removed… I can move the clips on top of another group but the transitions stay behind on the primary (Magnetic)
    In the screen shot you can see what happens when I move a group out of the primary (magnetic) timeline onto a gap.  All the transitions get left behind. 
    Ive notices that Cutting and pasting will only paste the sequence some other place on the primary (magnetic) timeline for me.
    An example of why I would want to put a cropped/ resized group on top of another group is to do picture in picture effects or if I wanted to create a background behind a set of adjusted clips.

  • How to handle multiple clients with DatagramSocket

    I am trying to handle multiple clients with 1 datagramSocket bind to one port (basically I have only one port to use, and I can not use TCP or any other ports). At the server side I have two threads one for receiving packets and buffering them, another for processing the packets in the buffer and sending replies.
    I can have multiple clients sending datagramPackets to me and I will have to process the packets and send them to DIFFERENT clients. Ex. Client 1 sends datagramPacket to Server which sends the processed packet to Client 2. Also Client 2 sends a datagramPacket to Server which again processes the packet and sends it to Client1. May have Client 3 and 4 doing the same thing at the same time... and so on...
    My root class is creating the datagramSocket(somePort) and two threads (receiver and sender). How can I use the socket that I created in these two threads??
    I have done the following and I am getting "java.net.bindexception". When I am sending stuff from Client1 to Client2 everything is fine but when I start sending something from Client2 to Client 1, I get the bindexception... Client 1 is using port 3000, Client 2 is using port 4000.
    I really don't have a lot of experience in socket programming so I am not sure if there is a much simpler way to do this. I appreciate all the tips and help that I can get...
    Thanks...
    class UDP_serv
         static DatagramSocket udpSocket;
         final static int SERVER_PORT     = 2000;
         public static void main(String[] args) throws SocketException
              udpSocket= new DatagramSocket(SERVER_PORT);
              new DataReceiver().start ();
              new DataSender().start ();
         static class DataReceiver extends Thread
              DataReceiver()
                   Thread.currentThread().setName("DataReceiver");
              public void run()
                   while (true)
                        byte pckt[] = new byte [MaxMsgSize];          
                        DatagramPacket dp = new DatagramPacket (pckt, pckt.length);
                        try
                             udpSocket.receive (dp);
                             //PUSH TO RECEIVE BUFFER
                        catch(Exception e)
                             e.printStackTrace();
         static class DataSender extends Thread
              DataSender()
                   Thread.currentThread().setName("DataSender");
              public void run()
                   while (true)
                        processDataMsg();
          static void processDataMsg() 
             DatagramPacket op;
             InetAddress DA = null;
             int DP = 0;
             byte [] outPacket = null;
             // POP FROM RECEIVE BUFFER
             // SOME PROCESSING HERE     
             // Set Destination Address (DA)
             // Set Destination Port (DP)
             // DA and DP are the forwarding IP and Port addresses
             // not the addresses original packet was sent from.
             try
              op = new DatagramPacket (outPacket, outPacket.length,DA, DP);
              udpSocket.send(op);
             catch (IOException e)
              e.printStackTrace();
    }Also for development and testing purposes, I am running the two clients and the server on the same machine (windows xp-32b) so all of the Destination IP Addresses are 127.0.0.1. and as I said Ports that I am using are 2000, 3000, 4000 (Server, Client1, Client2).

    Hmm I have minimized the code and it seems to be working now.
    I think I have an error in the header portion of the data I am sending, where I am storing the source IP/Port and destination IP/Port. I think the server in the middle is messing these values up while sending them to the destination Client. Because the destination client actually receives the stuff and sends the reply back to the server, but the reply packet's headers has 0/0 as the dest IP / Port...
    Server is giving me java.net.BindException: Cannot assign requested address error when it tries to forward the reply it received from the client2 as the address it is trying to send is 0!
    I guess it doesnt just give this error when you try to open two sockets to the same port...
    Paul, Thanks for the direction on how to proceed... took me a while get the minimized code but at least figured out the problem. Well still have to make sure that is THE problem though :)
    As far as the statics goes how can I change those to non static ones? Where do I make an instance of the top level class that creates the threads? and how do I pass the DatagramSocket to the threads/ if I dont need to pass how do I call or use the datagramSocket I created in the top level class? I mean do I still kinda have it like a global variable on the top?? A very simple example would be much appreciated...
    I think these might be really basic questions but I am having a rough time with the hierarchy in java...

  • How to do that - Validation with message

    Hi
    I have a litle app that validates one Portuguese Number (NIF).
    The purpose is create a textbox where the user put the number and then when press tue button, it validate then.
    I've tried do that with the validation, with a plsql function returnig boolean... it works fine when the number is wrong...
    the error message was fine... how can i implement a sucess message...
    Sugestions are welcome.
    Another question.... How can i costumize the standard error message?
    Sorry for the bad english
    Thanks

    José,
    Yes that would work. Because you're catching all of the incorrect entries with a validation, the PL/SQL process will never run unless you have the validation is TRUE. This means the process code can always complete successfully because the validation already did the work. So the process need be only one line:
    NULL;
    Then create the success message as you like and test it. Keep in mind that a process success message may look different from a validation failure message. You might have to modify the look a bit to get them consistent if that's necessary.
    Dan

  • How to schedule multiple reports with different local to change static field language ?

    Hi all,
    we have requirement that we will place multiple schedule request on same server ,This schedule request will be different local setting with parameter value like: en-GB,en-US,Chinese...etc .We used translation Manager for this and it takes this parameter and change report language for static fields.
    problem is that ,on server it is not working properly,we tested for one report .if we pass prompt value to change local setting in report the we need to log off and login again in CMC to reflect new local or on BI Launchpad we need to refresh page then it shows new language.
    How we can do this with multiple scheduled report which will have different local value like en-GB,en-US,Chinese,German....?These schedule request are getting placed in server by one user .
    Please help us with sample code.
    Thanks
    Madan

    Hi,
    The only approach I can think of is to create a template report which uses variables
    For each column you would need to variable
    v_columnAName and v_columnAValue
    v_columnAName would have a if statement in it
    =if([client]="clientA" or [client]="clientC";NameOf([firstName]);if([client]="clientB";NameOf([SSN]);NameOf([lastName]));
    v_columnA would have a if statement in it
    =if([client]="clientA" or [client]="clientC";[firstName];if([client]="clientB";[SSN],[lastName]));
    This would only work when you had a small set of clients.
    This might be more managable if it was done in the universe
    Regards
    Alan

  • How to avoid multiple LOGIN with same user in database.

    Hi All,
    Using database triggers how to control multiple logins of a pertiuclar user.
    thanks in advance

    Don't forget to activate the RESOURCE_LIMIT parameter, which default is FALSE :
    alter system set RESOURCE_LIMIT = true;
    Laurent, I had a similar problem some time ago : I didn't want to avoid multiple access, but only control who was doing what. That's because moving from Client/Server to Web the TERMINAL column in V$SESSION becomes useless.
    I tried your solution, but I had to give up with it, because in my Forms9i application some forms call Reports, which generate a new session.
    I decided to use DBMS_APPLICATION_INFO, and this is satisfactory for my requirements, but I'm interested to discover other solutions.
    P.S. with my solution I'm able to limit accesses, because in the CLIENT_INFO string I put, among other things, the
    application user, so I can control if an user is already connected. The problem is that existing applications have to be modified .....:-(

  • How to scan multiple pages with Photosmart 6510?

    Hi,
    I am a new user of Photosmart 6510 All-in-One printer. Does anyone know how to scan multiple pages into one document? 
    Thanks!
    This question was solved.
    View Solution.

    You can do multiple pages to one file by selecting Scan to PDF. You will have to start the scan using the HP Software. Follow the steps below to do a multipage scan.
    1. On the desktop, look for the Photosmart 6510 icon. Double click it
    2. Click Scan Document
    3. Click Save as PDF and the click Scan. The all-in-one will do a preview scan.
    4. Load the next document page on the scan bed
    5. Click the button with the plus sign on the lower left hand corner of the preview window. The all in one will scan the page. Keep doing this until you have scanned all the pages.
    6. Click on the Save button and follow the instructions on the screen.
    Binary_Zen (worked at HP )
    Click the white Kudos star to say thanks
    Please mark Accept As Solution if it solves your problem

  • How to install multiple packages with pacman?

    Hi ,
    I guess it's a pretty noobish question but I wonder how to install multiple packages
    that have the same prefix with Pacman.
    To make myself more clear, I like to install all gstreamer packages and for that I would
    like something similar to
    pacman -S gstreamer10*
    Is there a command that does something like this available? Found nothing in the man pages.
    Maybe some tricky stuff with pipes?

    sH wrote:Hi ibendiben,
    thanks for your help, but I'm afraid, it does not work
    I'm so sorry, my fault, I couln't test it, and made some big mistakes.
    This time it's working:
    pacman -S $(pacman -Ss gstreamer0.10 | sed -n 's#^\([^/]*/gstreamer0.10[^ ]*\) .*$#\1#p')

  • How to send multiple attachemnt with a Email

    Hello experts,
    I have problem with sending multiple attachement with a Email .
    I have used program BCS_EXAMPLE_5. it is not for multiple attachment.
    Please help me.
    Thank you.

    Hello,
    u can make use of these Function Modules.
    SO_DOCUMENT_SEND_API1
    SO_NEW_DOCUMENT_SEND_API1
    'CONVERT_OTFSPOOLJOB_2_PDF'
    the program which u gave using the method classes
    Thank u,
    santhosh
    Edited by: santhosh kumar on Dec 2, 2008 2:15 PM

  • How to backup multiple iphones with different iCloud accounts but same apple id?

    I would like to back up 3 idevices each with different icloud accounts to itunes. But they use the same apple id so that itune purchases can be installed on each device (2 iphones and 1 ipad).
    All I want to do is create a backup in case the phones need to be restored. I also want to back up before downloading iOS 8.
    The Macbook Pro that I will back up to has one user and one itunes library.
    Is this possible without mixing up address books and contacts etc? Appreciate if some one could direct me to detail step-by-step instructions if they exist or please tell me how I can do this.
    Thanks.

    With Family Sharing they don't need to have the same Apple ID anymore.
    But backups to iTunes are kept separate among multiple devices; Apple ID and iCloud isn't involved at all. Just make sure the devices do not have the same name.

  • How  to use multiple channels with one remoteObject .

    hi,
    I have an application which is accessed through HPPS some
    times , also it can be access on server with http service.
    so I want to know how to configure config files or add
    runtime channels which will support either channel depending on
    the server it is accessed over.
    Is there any one who can help me to solve this...i need it
    soon.
    thank you...

    Hi,
    Please visit the URL below for details on adding channel sets
    at runtime. Add multiple channels to the channel set so that the
    fall back mechanism works.
    http://livedocs.adobe.com/blazeds/1/blazeds_devguide/runtimeconfig_5.html#194376
    Hope this helps.

  • Household of iPhones -- How to Sync multiple iPhones with Multiple Computer

    We just purchased two iPhones, one for me and one for my wife. Awesome so far, activation was a breeze, no problem getting on our wifi network. Now we're choosing what to sync. We have two computers -- one macpro for me, a powerbook g4 for my wife. We keep all of our iLife stuff on my computer (all itunes songs, all iphoto pictures, etc.). We keep our respective e-mail, contacts, and calendars on our respective computers.
    How should synching work? For me, it's just my computer so no issue. But for my wife, I seem to need to sync once with my computer for music/pictures, then once with her computer for her mail/contacts/calendar. Is this possible?

    Hey W.Scheinler,
    It is possible to sync the phones from multiple computers, for example you can sync your music from your Mac Pro and Contacts from the Powerbook G4.
    This article: http://docs.info.apple.com/article.html?artnum=305741 will give more detailed information.
    Jason

  • How to use multiple senders with one account

    I have not moved from Entourage to Mail because I cannot figure out how to change sender addresses while using the same SMTP server.
    It is easy to do in Entourage. Is it possible in Mail?
    Thanks

    Not sure what you mean, but associating multiple email addresses with the same mail account is described in Mail Help’s “Adding multiple email alias addresses to an account” article.

Maybe you are looking for

  • DW wont open PHP file

    I have a PHP page that include();s a file that contains the page's <html> tag and <head> and <frameset> sections ending with a <noframe> tag. When I open this page in DW, I find the DW has been quite confused by the file - it opens the source file of

  • Cannot view files from utube.

    When on utube, I cant view movies or video. Says I need to download new version of adobe flash player. But I have downloaded current version. But still cant view videos.

  • Multi Language Smart Forms

    Hi I need to display multipile languages in same form my main language is english first the language will be in japaneese followed by english and french but everthing has to be displayed in the same page. japaneese English french any guidence in this

  • How to change language in Namoroka

    hello i have the 64bit version of firefox - namoroka , and it is in english , do somebody know how to change it into hebrew? thank you very much uriel == User Agent == Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100405 Namorok

  • Does Photoshop CS3 Extended support Thai fonts?

    I am translating some short text in Photoshop to several Asian languages. I noticed just with the Thai language, that I get a series of X's with boxes instead of Thai characters. The characters are fine in other applications, including Flash CS3. Oth