Alert needed on losing focus from Editable Rdcombox if text entered does not match

4 posts, 0 answers
  1. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 15 Nov 2011 Link to this post

    Hi,


    I have radcombobox which is

    IsEditable="True" 
    IsTextSearchEnabled="True" 
    TextSearchMode="StartsWith"

     
    Now when user enters some text which is not present in the list that is binded to the radcombobox and the radcombobox loses focus, i want a alert which tells users that value entered is not available and clears the text entered in the radcombobox.

    Please guide.

     

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Nov 2011 Link to this post

    Hi Manishkumar,

    Please find attached a simple example which demonstrates how you can implement validation in RadComboBox.

    Hope it helps.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 18 Nov 2011 Link to this post

    Hi Yana,

    Thanks for replying.
    The example provided is not helping though. I can enter wrong values in the radcombobox and even on losing focus, no alert is thrown to the user.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Nov 2011 Link to this post

    Hello Manishkumar,

    I've modified the XAML from the project to show how to set ErrorTemplate:

    <Window.Resources
        <ControlTemplate x:Key="ErrorTemplate">
            <DockPanel LastChildFill="True">               
                <TextBlock DockPanel.Dock="Top"
                            Text="{Binding ElementName=comboBox,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                            Foreground="Red"                           
                            FontWeight="Bold"/>
                <Border BorderBrush="Red" BorderThickness="1">
                    <AdornedElementPlaceholder Name="comboBox" />
                </Border>
            </DockPanel>
        </ControlTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
            <telerik:RadComboBox x:Name="comboBox" IsEditable="True" Width="300" Height="22"
                            IsTextSearchEnabled="True"
                            TextSearchMode="StartsWith"
                            ItemsSource="{Binding Items}"
                            SelectedValue="{Binding SelectedItem, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                            Validation.ErrorTemplate="{StaticResource ErrorTemplate}"       />
            <Button Content="click" Grid.Row="1" Width="50" Height="22" />
    </Grid>

    Hope this helps.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top