This is a migrated thread and some comments may be shown as answers.

Error template with implicit styles

3 Answers 105 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 18 Apr 2016, 01:27 PM

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>

3 Answers, 1 is accepted

Sort by
0
Vikas
Top achievements
Rank 1
answered on 18 Apr 2016, 01:46 PM

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>

 

 

0
Masha
Telerik team
answered on 19 Apr 2016, 06:52 AM
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.
0
Vikas
Top achievements
Rank 1
answered on 20 Apr 2016, 01:38 PM
Yes it is working in your example, I am able to get around my problem by giving my style a key.
Tags
ComboBox
Asked by
Vikas
Top achievements
Rank 1
Answers by
Vikas
Top achievements
Rank 1
Masha
Telerik team
Share this question
or