Error template with implicit styles

4 posts, 0 answers
  1. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 18 Apr Link to this post

    I am using implicit styles and want to display a custom error template for RadCombobox. This is my style, It was working fine when i was not using implicit styles, but after that when ever there is an error it display the default telerik error template a red border with tooltip at right top corner.

     

    <telerik:RadComboBox Width="260" ItemsSource="{Binding Policies}" DisplayMemberPath="Name" 
                                     SelectedItem="{Binding SelectedPolicy, NotifyOnValidationError=True}"/>

    <Style TargetType="{x:Type telerik:RadComboBox}" BasedOn="{StaticResource RadComboBoxStyle}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="True">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                    <Setter Property="BorderBrush" Value="Red"/>
                    <Setter Property="Validation.ErrorTemplate">
                        <Setter.Value>
                            <ControlTemplate>
                                <DockPanel>
                                    <TextBlock Foreground="Red" Text="{Binding [0].ErrorContent}" TextTrimming="WordEllipsis" DockPanel.Dock="Bottom" />
                                    <AdornedElementPlaceholder/>
                                </DockPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>

  2. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 18 Apr in reply to Vikas Link to this post

    It is some other problem, It works if i put the style in the  XAML file where the combo box is defined or if I give a key to the style and apply that style explicitly to my combo box, I want to apply this style to all the combo boxes and was hoping that if i just create style targeting a type it will apply to all.

    I am actually developing an addin and because of that I do not have an app.xaml file. I am developing my UI as user controls and the hosting application initialize the user control and display it inside the main window.

    My project structure is like this, I have a folder that contains all the implicit themes and also my custom resource dictionary, In my custom resource dictionary i am referencing all the implicit styles

    <ResourceDictionary.MergedDictionaries>        
            <ResourceDictionary Source="../Vista/System.Windows.xaml" />
            <ResourceDictionary Source="../Vista/Telerik.Windows.Controls.xaml" />
            <ResourceDictionary Source="../Vista/Telerik.Windows.Controls.GridView.xaml" />
            <ResourceDictionary Source="../Vista/Telerik.Windows.Controls.Navigation.xaml" />
            <ResourceDictionary Source="../Vista/Telerik.Windows.Controls.Data.xaml" />
            <ResourceDictionary Source="../Vista/Telerik.Windows.Controls.Input.xaml" />
        </ResourceDictionary.MergedDictionaries>

    And My view(user control) is referencing the custom dictionary

    <UserControl.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>                
                    <ResourceDictionary Source="../../Themes/Custom/Common.xaml"/>
                    <ResourceDictionary Source="../../Themes/Custom/RadButtonStyle.xaml"/>
                </ResourceDictionary.MergedDictionaries>
                <conv:EnumFilterConverter x:Key="enumFilterConverter"/>
            </ResourceDictionary>
        </UserControl.Resources>

     

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Masha
    Admin
    Masha avatar
    355 posts

    Posted 19 Apr Link to this post

    Hello Vikas,

    I'm afraid I was not able to reproduce the described problem. I've created a simple RadComboBox validation and have applied your validation style. It seems that everything works as expected. Can you check it if you can reproduce the issue in the attached project.

    Looking forward to receiving your reply.

    Regards,
    Masha
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Vikas
    Vikas avatar
    36 posts
    Member since:
    Dec 2015

    Posted 20 Apr in reply to Masha Link to this post

    Yes it is working in your example, I am able to get around my problem by giving my style a key.
Back to Top