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

How to customize EditRecurrenceDialogStyle and EditAppointmentDialogStyle in same time ?

3 Answers 30 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Gael
Top achievements
Rank 1
Gael asked on 25 Sep 2018, 04:05 PM

Hi everyone,

I would like to customize the AppointmentDialog and the RecurrenceDialog in same time but I have a problem.

So, I made in two ResourceDictionary a ControlTemplate foreach Dialog.

  • <ControlTemplate x:Key="EditAppointmentTemplate" TargetType="telerik:SchedulerDialog">...</ControlTemplate >
  • <ControlTemplate x:Key="EditRecurrenceTemplate" TargetType="telerik:SchedulerDialog">...</ControlTemplate >

After that, I create another ResourceDictionary where I define the Styles :

  •                     <Style BasedOn="{StaticResource EditRecurrenceDialogStyle}" TargetType="telerik:SchedulerDialog" x:Key="EditRecurrenceDialogStyle">
                            <Setter Property="Template" Value="{StaticResource EditRecurrenceTemplate}"/>
                        </Style>
  •                     <Style BasedOn="{StaticResource EditAppointmentDialogStyle}" TargetType="telerik:SchedulerDialog" x:Key="EditAppointmentDialogStyle">
                            <Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}"/>
                        </Style>

Then, in the telerik:RadScheduleView I set the proprieties in the following way :

  •             <telerik:RadScheduleView
                                        ...
                                        AppointmentsSource="{Binding Appointments}"
                                        EditRecurrenceDialogStyle="{StaticResource EditRecurrenceDialogStyle}"
                                        EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}"
                                        ...>

When I test the styles individually it works. However when I test with both styles define, I have this error:

  • ArgumentException: Item has already been added. Key in dictionary: 'Telerik.Windows.Controls.SchedulerDialog'  Key being added: 'Telerik.Windows.Controls.SchedulerDialog'

How can I fix that ?
Thanks in advance for your help.

3 Answers, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 28 Sep 2018, 10:22 AM
Hello Gael,

Looking at the provided code snippet I can't something which could lead to this exception. I am attaching the sample project which I used to test your scenario. Can you take a look at this project and let me know what I am missing from your implementation in order to reproduce this exception?

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gael
Top achievements
Rank 1
answered on 01 Oct 2018, 01:11 PM
Hi Dinko,

Thank you for your interest in my question.
At first I want to clarify that I use a UserControl.Resources and a ResourceDictionary.MergedDictionaries. My hierarchy is as follows:
<UserControl.Resources>
    <ResourceDictionary>
         <ResourceDictionary.MergedDictionaries>
               <ResourceDictionary> ... </ ResourceDictionary>
               <ResourceDictionary> ... </ ResourceDictionary>
               <ResourceDictionary>
                     <ControlTemplate ...> ... </ ControlTemplate>
               </ ResourceDictionary>
               <ResourceDictionary>
                     <ControlTemplate ...> ... </ ControlTemplate>
               </ ResourceDictionary>
               <ResourceDictionary>
                     <Style ...> ... </ style>
                     <Style ...> ... </ style>
               </ ResourceDictionary>
          </ ...>
    </ ...>
</UserControl.Resources>

I use your project to test.
I placed my ControlTemplate and my styles directly in Window.Resources, it works. However, I realized another try but this time keeping my hierarchy and it did not work and I find myself with the same error.
I also did tests on my project trying to put only ControlTemplate and styles in UserControl.Resources but this time I find myself with another error telling me that it can not find the resource named EditRecurrenceDialogStyle .

Regards
0
Gael
Top achievements
Rank 1
answered on 01 Oct 2018, 01:39 PM
Re,

I found my mistake.

The problem came from the fact that I started my ControlTemplate in a resourceDictionary ...

The good hierarchy is:
<UserControl.Resources>
     <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary> ... </ ResourceDictionary>
                <ResourceDictionary> ... </ ResourceDictionary>
          </ResourceDictionary.MergedDictionaries>
         <ControlTemplate ...> ... </ ControlTemplate>
         <ControlTemplate ...> ... </ ControlTemplate>
         <Style> ... </ style>
         <Style> ... </ style>
     </ ResourceDictionary>
</UserControl.Resources>

Sorry for the inconvenience.
Have a nice day.
Tags
ScheduleView
Asked by
Gael
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Gael
Top achievements
Rank 1
Share this question
or