Wizard like PanelBar validation.

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    227 posts
    Member since:
    Apr 2007

    Posted 28 Jul 2010 Link to this post

    hi, I try to do a small wizard for creating a new address. I got an entity (EF) address that a instantiate at the beginning of the wizard:
    NouvAdresse = new Adresse();

    On the first page wizard (each step are in different RadpanelItem). I got 4 textbox binded to the Adresse entity like:
    <TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding wizAjouteAdresseRes.lblDestinataire, Source={StaticResource ResourceWrapper}}" HorizontalAlignment="Right" VerticalAlignment="Top"></TextBlock>

    The validation present in the EF metadata work well. But if a textbox can't be empty and the user do not enter any value For example he just do a tab over it), the validation do not occur because the text are not changed.

    To avoid that I create a function called in the Click event of the button to force the validation of all the currently wizard section:

    private void ForceValidation(Grid Container)
        foreach(var ctrl in Container.Children)
            if (ctrl is TextBox)
                (ctrl as TextBox).GetBindingExpression(TextBox.TextProperty).UpdateSource();

    That work, but how I can detect if no validation error as been raise for let the user go to next step? For now the user change step either with validation error.
    The user will click on the Next button, then forced validation occurd and if all is ok the panel change..
    Any suggestion?
  2. Kiril Stanoev
    Kiril Stanoev avatar
    1512 posts

    Posted 02 Aug 2010 Link to this post

    Hello Pierre,

    You can attach to GotFocus and LostFocus events of the TextBox and force the validation from there. Have a look at this MSDN article on explicit validation. Once you are done with that, you can read this StackOverflow thread as it explains one possible way to handle and detect validation errors in Silverlight. Let me know if these help.

    Kind regards,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top