Unable to get items for a combobox inside EditAppointmentTemplate

3 posts, 1 answers
  1. Maxence
    Maxence avatar
    21 posts
    Member since:
    Aug 2011

    Posted 21 Sep 2011 Link to this post

    Hi,

    i have a custom appointment and i'm not able to bind a combobox inside the EditAppointmentDialog.
    I saw already a topic there about this problem : http://www.telerik.com/community/forums/silverlight/scheduleview/add-combobox-in-appointmentdialog.aspx but it doesn't work for me.

    Here the xaml for my silverlight page :

    <navigation:Page xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="FrontOffice.Silverlight.Saisie_Recurrente"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               mc:Ignorable="d"
               xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
               d:DesignWidth="640" d:DesignHeight="480"
               x:Name="PageSaisieRecurrente"
               Title="Saisie_Recurrente Page">
     
        <navigation:Page.Resources>
            <SolidColorBrush x:Key="RadScheduleForeground" Color="Black"/>
            <SolidColorBrush x:Key="RadScheduleBackground" Color="#FFFFFFFF"/>
            <telerik:Office_SilverTheme x:Key="Theme"/>
            <telerik:InvertedBooleanConverter x:Key="InvertedBooleanConverter"/>
            <DataTemplate x:Key="TimeMarkerComboBoxItemContentTemplate">
                <StackPanel Orientation="Horizontal">
                    <Rectangle Fill="{Binding TimeMarkerBrush}" Height="12" Margin="2 0" Width="12"/>
                    <TextBlock Margin="2 0" telerik:LocalizationManager.ResourceKey="{Binding TimeMarkerName}"/>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Key="CategoryComboBoxItemContentTemplate">
                <StackPanel Orientation="Horizontal">
                    <Rectangle Fill="{Binding CategoryBrush}" Height="12" Margin="2 0" Width="12"/>
                    <TextBlock Margin="2 0" Text="{Binding DisplayName}"/>
                </StackPanel>
            </DataTemplate>
            <telerik:LocalizationManager x:Key="LocalizationManager"/>
            <telerik:BoolToInputModeConverter x:Key="BoolToInputModeConverter"/>
            <telerik:ResourcesSeparatorConverter x:Key="ResourcesSeparatorConverter"/>
            <telerik:ResourceTypeTemplateSelector x:Key="ResourcesEditorItemTemplateSelector">
                <telerik:ResourceTypeTemplateSelector.MultipleSelectionTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Margin="6" Text="{Binding ResourceType.DisplayName}"/>
                            <telerik:RadComboBox ClearSelectionButtonContent="{Binding ClearAllButtonContent}" Grid.Column="1" ClearSelectionButtonVisibility="Visible" ItemsSource="{Binding ResourceItems}" Margin="3" SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}">
                                <telerik:RadComboBox.ItemContainerStyle>
                                    <Style TargetType="telerik:RadComboBoxItem">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <CheckBox Content="{Binding Resource.DisplayName}" IsChecked="{Binding IsChecked, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </telerik:RadComboBox.ItemContainerStyle>
                                <telerik:RadComboBox.SelectionBoxTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Owner.CheckedItems, Converter={StaticResource ResourcesSeparatorConverter}}"/>
                                    </DataTemplate>
                                </telerik:RadComboBox.SelectionBoxTemplate>
                            </telerik:RadComboBox>
                        </Grid>
                    </DataTemplate>
                </telerik:ResourceTypeTemplateSelector.MultipleSelectionTemplate>
                <telerik:ResourceTypeTemplateSelector.SingleSelectionTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Margin="6" Text="{Binding ResourceType.DisplayName}"/>
                            <telerik:RadComboBox ClearSelectionButtonContent="{Binding ClearAllButtonContent}" Grid.Column="1" ClearSelectionButtonVisibility="Visible" DisplayMemberPath="Resource.DisplayName" ItemsSource="{Binding ResourceItems}" Margin="3" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                        </Grid>
                    </DataTemplate>
                </telerik:ResourceTypeTemplateSelector.SingleSelectionTemplate>
            </telerik:ResourceTypeTemplateSelector>
            <telerik:InvertedVisibilityConverter x:Key="InvertedVisibilityConverter"/>
            <telerik:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter"/>
            <telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <telerik:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
            <telerik:InvertedNullToVisibilityConverter x:Key="InvertedNullToVisibilityConverter"/>
            <ImageSource x:Key="EditAppointmentTemplate_Recurrence">/Telerik.Windows.Controls.ScheduleView;component/Themes/Images/Recurrence.png</ImageSource>
            <ControlTemplate x:Key="EditAppointmentTemplate" TargetType="telerik:SchedulerDialog">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <telerik:RadToolBar x:Name="AppointmentToolbar" GripVisibility="Collapsed" Margin="-1 -1 -1 3" Grid.Row="0" telerik:StyleManager.Theme="{StaticResource Theme}">
                        <telerik:RadButton x:Name="EditRecurrenceButton" Command="telerik:RadScheduleViewCommands.EditRecurrenceRule" Visibility="{Binding CanEditParentAppointment, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
                            <ToolTipService.ToolTip>
                                <ToolTip telerik:LocalizationManager.ResourceKey="EditRecurrence" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            </ToolTipService.ToolTip>
                            <StackPanel Margin="2 0" Orientation="Horizontal">
                                <Image Margin="2 0" Source="{StaticResource EditAppointmentTemplate_Recurrence}" Stretch="None"/>
                                <TextBlock Foreground="{StaticResource RadScheduleForeground}" Margin="4 0" telerik:LocalizationManager.ResourceKey="EditRecurrence"/>
                            </StackPanel>
                        </telerik:RadButton>
                        <telerik:RadButton x:Name="EditParentAppointmentButton" Command="telerik:RadScheduleViewCommands.EditParentAppointment" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Visibility="{Binding CanEditParentAppointment, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <ToolTipService.ToolTip>
                                <TextBlock telerik:LocalizationManager.ResourceKey="EditParentAppointment" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            </ToolTipService.ToolTip>
                            <TextBlock Foreground="{StaticResource RadScheduleForeground}" Margin="4 0" telerik:LocalizationManager.ResourceKey="EditParentAppointment"/>
                        </telerik:RadButton>
                        <telerik:RadToolBarSeparator/>
                        <TextBlock x:Name="ShowAs" Foreground="{StaticResource RadScheduleForeground}" Margin="1 0 1 1" telerik:LocalizationManager.ResourceKey="ShowAs" VerticalAlignment="Center"/>
                        <telerik:RadComboBox x:Name="PART_TimeMarkers" ClearSelectionButtonContent="{Binding ClearSelectionButtonContent}" ClearSelectionButtonVisibility="Visible" EmptyText="{Binding TimeMarkersEmptyText}" ItemTemplate="{StaticResource TimeMarkerComboBoxItemContentTemplate}" ItemsSource="{Binding TimeMarkers}" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Margin="2 1" SelectionBoxTemplate="{StaticResource TimeMarkerComboBoxItemContentTemplate}" SelectedItem="{Binding Occurrence.Appointment.TimeMarker, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}" Width="110"/>
                        <telerik:RadComboBox x:Name="PART_Categories" ClearSelectionButtonContent="{Binding ClearSelectionButtonContent}" ClearSelectionButtonVisibility="Visible" EmptyText="{Binding CategoriesEmptyText}" ItemTemplate="{StaticResource CategoryComboBoxItemContentTemplate}" ItemsSource="{Binding Categories}" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Margin="2 1" SelectionBoxTemplate="{StaticResource CategoryComboBoxItemContentTemplate}" SelectedItem="{Binding Occurrence.Appointment.Category, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}" Width="120"/>
                        <telerik:RadToggleButton x:Name="HighImportaceButton" Height="22" IsChecked="{Binding IsHighImportance, Mode=TwoWay}" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Width="22">
                            <ToolTipService.ToolTip>
                                <ToolTip telerik:LocalizationManager.ResourceKey="HighImportance" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            </ToolTipService.ToolTip>
                            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Path Data="M200.39647,58.840393 C200.39337,58.336426 201.14566,57.683922 202.56244,57.684292 C204.06589,57.684685 204.73764,58.357765 204.72783,58.992363 C205.04649,61.795574 203.04713,64.181099 202.47388,66.133446 C201.93753,64.154961 199.9471,61.560352 200.39647,58.840393 z" HorizontalAlignment="Center" Height="10" Stretch="Fill" Width="5.451">
                                    <Path.Fill>
                                        <LinearGradientBrush EndPoint="1.059,0.375" StartPoint="-0.457,0.519">
                                            <GradientStop Color="#FFFF0606" Offset="0.609"/>
                                            <GradientStop Color="#FFBF0303" Offset="0.927"/>
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Ellipse HorizontalAlignment="Center" Height="3" Width="3">
                                    <Ellipse.Fill>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#FFFF0606" Offset="0"/>
                                            <GradientStop Color="#FFBF0303" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                            </StackPanel>
                        </telerik:RadToggleButton>
                        <telerik:RadToggleButton x:Name="LowImportaceButton" Height="22" IsChecked="{Binding IsLowImportance, Mode=TwoWay}" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Width="22">
                            <ToolTipService.ToolTip>
                                <ToolTip telerik:LocalizationManager.ResourceKey="LowImportance" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            </ToolTipService.ToolTip>
                            <Path Data="M222.40353,60.139881 L226.65768,60.139843 L226.63687,67.240196 L229.15347,67.240196 L224.37816,71.394943 L219.65274,67.240196 L222.37572,67.219345 z" HorizontalAlignment="Center" Height="12" Stretch="Fill" Stroke="#FF0365A7" VerticalAlignment="Center" Width="9">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="1.059,0.375" StartPoint="-0.457,0.519">
                                        <GradientStop Color="#FFBBE4FF"/>
                                        <GradientStop Color="#FF024572" Offset="0.836"/>
                                        <GradientStop Color="#FF43ADF4" Offset="0.466"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                        </telerik:RadToggleButton>
                    </telerik:RadToolBar>
                    <Border x:Name="AppointmentCategory" Background="{Binding SelectedItem.CategoryBrush, ElementName=PART_Categories}" CornerRadius="3" Height="20" Margin="6 6" Grid.Row="1" Visibility="{Binding SelectedItem, Converter={StaticResource NullToVisibilityConverter}, ElementName=PART_Categories}">
                        <TextBlock Margin="6 0" Text="{Binding SelectedItem.DisplayName, ElementName=PART_Categories}" VerticalAlignment="Center"/>
                    </Border>
                    <Grid x:Name="Details" Margin="6" Grid.Row="2">
                        <Grid.Resources>
                            <telerik:InputMode x:Key="RadDateTimePickerInputModeDatePicker">DatePicker</telerik:InputMode>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="0" telerik:LocalizationManager.ResourceKey="Subject"/>
                        <TextBox Grid.ColumnSpan="2" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" Margin="3" Grid.Row="0" Text="{Binding Occurrence.Appointment.Subject, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="1" telerik:LocalizationManager.ResourceKey="Body"/>
                        <TextBox Grid.ColumnSpan="2" Grid.Column="1" Height="70" IsReadOnly="{Binding IsReadOnly}" Margin="3" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Occurrence.Appointment.Body, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" telerik:StyleManager.Theme="{StaticResource Theme}" VerticalScrollBarVisibility="Visible" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="2" telerik:LocalizationManager.ResourceKey="StartTime"/>
                        <telerik:RadDateTimePicker Culture="{Binding DefaultCulture, Source={StaticResource LocalizationManager}}" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" IsEnabled="{Binding IsNotRecurrent}" Margin="3" Grid.Row="2" SelectedValue="{Binding ActualStart, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnDataErrors=true}" telerik:StyleManager.Theme="{StaticResource Theme}">
                            <telerik:RadDateTimePicker.InputMode>
                                <Binding Converter="{StaticResource BoolToInputModeConverter}" Path="IsAllDayEvent">
                                    <Binding.ConverterParameter>
                                        <telerik:InputMode>DatePicker</telerik:InputMode>
                                    </Binding.ConverterParameter>
                                </Binding>
                            </telerik:RadDateTimePicker.InputMode>
                        </telerik:RadDateTimePicker>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="3" telerik:LocalizationManager.ResourceKey="EndTime" telerik:StyleManager.Theme="{StaticResource Theme}" VerticalAlignment="Center"/>
                        <telerik:RadDateTimePicker Culture="{Binding DefaultCulture, Source={StaticResource LocalizationManager}}" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" IsEnabled="{Binding IsNotRecurrent}" Margin="3" Grid.Row="3" SelectedValue="{Binding ActualEnd, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnDataErrors=true}" telerik:StyleManager.Theme="{StaticResource Theme}">
                            <telerik:RadDateTimePicker.InputMode>
                                <Binding Converter="{StaticResource BoolToInputModeConverter}" Path="IsAllDayEvent">
                                    <Binding.ConverterParameter>
                                        <telerik:InputMode>DatePicker</telerik:InputMode>
                                    </Binding.ConverterParameter>
                                </Binding>
                            </telerik:RadDateTimePicker.InputMode>
                        </telerik:RadDateTimePicker>
                        <CheckBox Grid.Row="9" Grid.Column="1" Margin="3" Content="Reunion ?" IsChecked="{Binding Occurrence.Appointment.IsMeeting, Mode=TwoWay}"/>
                        <CheckBox Grid.Row="6" Grid.Column="1" Margin="3" Content="Heure supplémentaire ?" IsChecked="{Binding Occurrence.Appointment.IsAdditionalHour, Mode=TwoWay}"/>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="7" Text="Métier" />
                        <TextBox Grid.ColumnSpan="2" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" Margin="3" Grid.Row="7" Text="{Binding Occurrence.Appointment.Occupation, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                        <TextBlock Grid.Column="0" Margin="6" Grid.Row="8" Text="Type"/>
                        <TextBox Grid.ColumnSpan="2" Grid.Column="1" IsReadOnly="{Binding IsReadOnly}" Margin="3" Grid.Row="8" Text="{Binding Occurrence.Appointment.Type, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                        <telerik:RadComboBox x:Name="cmbProjects" Grid.Row="5"  Grid.Column="1" ItemsSource="{Binding ElementName=RecurrentScheduleView, Path=DataContext.Projets, Mode=TwoWay}" SelectedValue="{Binding Path=Occurrence.Appointment.Project, Mode=TwoWay}" DisplayMemberPath="Libelle" Margin="2 1" DropDownOpened="cmbProjects_DropDownOpened" />
                    </Grid>
                    <Grid Margin="3" Grid.Row="3" Visibility="{Binding ResourceTypesVisibility}">
                        <telerik:ItemsControl x:Name="PART_Resources" BorderBrush="{x:Null}" BorderThickness="0" HorizontalContentAlignment="Stretch" IsTabStop="false" ItemsSource="{Binding ResourceTypes}" ItemTemplateSelector="{StaticResource ResourcesEditorItemTemplateSelector}" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Margin="3" Visibility="{Binding ResourceTypesVisibility}" VerticalContentAlignment="Stretch"/>
                        <TextBlock HorizontalAlignment="Center" Margin="3" Text="You can only change the resources by opening the series" Visibility="{Binding ResourceTypesVisibility, Converter={StaticResource InvertedVisibilityConverter}}"/>
                    </Grid>
                    <StackPanel HorizontalAlignment="Right" Margin="13 6" Orientation="Horizontal" Grid.Row="4">
                        <telerik:RadButton Command="telerik:WindowCommands.Confirm" Margin="2" MinWidth="84" telerik:LocalizationManager.ResourceKey="Ok" telerik:RadWindow.ResponseButton="Accept" telerik:StyleManager.Theme="{StaticResource Theme}">
                            <ToolTipService.ToolTip>
                                <TextBlock telerik:LocalizationManager.ResourceKey="SaveAndClose" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                            </ToolTipService.ToolTip>
                        </telerik:RadButton>
                        <telerik:RadButton Command="telerik:WindowCommands.Cancel" Margin="2" MinWidth="84" telerik:LocalizationManager.ResourceKey="Cancel" telerik:RadWindow.ResponseButton="Cancel" telerik:StyleManager.Theme="{StaticResource Theme}"/>
                    </StackPanel>
                </Grid>
            </ControlTemplate>
            <Style x:Key="EditAppointmentDialogStyle" TargetType="telerik:SchedulerDialog">
                <Setter Property="Foreground" Value="{StaticResource RadScheduleBackground}"/>
                <Setter Property="Width" Value="560"/>
                <Setter Property="IsTabStop" Value="False"/>
                <Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}"/>
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <StackPanel HorizontalAlignment="Left" MaxWidth="400" Orientation="Horizontal">
                                <TextBlock telerik:LocalizationManager.ResourceKey="Event" Visibility="{Binding Occurrence.Appointment.IsAllDayEvent, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                <TextBlock telerik:LocalizationManager.ResourceKey="Appointment" Visibility="{Binding Occurrence.Appointment.IsAllDayEvent, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"/>
                                <TextBlock Text=" - "/>
                                <TextBlock x:Name="SubjectTextBlock" Text="{Binding Occurrence.Appointment.Subject}" Visibility="{Binding Occurrence.Appointment.Subject, Converter={StaticResource NullToVisibilityConverter}}"/>
                                <TextBlock telerik:LocalizationManager.ResourceKey="Untitled" Visibility="{Binding Occurrence.Appointment.Subject, Converter={StaticResource InvertedNullToVisibilityConverter}}"/>
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="IconTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Image Source="/Telerik.Windows.Controls.ScheduleView;component/Themes/Images/EditAppointment.png" Stretch="None"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </navigation:Page.Resources>
        <!-- ScheduleView Style -->
         
        <Grid x:Name="LayoutRoot">
            <StackPanel Orientation="Vertical">
                <telerik:RadComboBox x:Name="cmbProjects2" ItemsSource="{Binding ElementName=RecurrentScheduleView, Path=DataContext.Projets, Mode=TwoWay}" DisplayMemberPath="Libelle" Margin="2 1"  />
            <telerik:RadScheduleView x:Name="RecurrentScheduleView"  AppointmentsSource="{Binding Imputations, Mode=TwoWay}" EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}" AppointmentCreated="RadScheduleView_ImputationCreated" AppointmentDeleted="RadScheduleView_ImputationDeleted" AppointmentEdited="RadScheduleView_ImputationEdited" DataContext="{Binding}">
                <telerik:RadScheduleView.ViewDefinitions>
                    <telerik:DayViewDefinition />
                    <telerik:WeekViewDefinition />
                    <telerik:MonthViewDefinition/>
                    <telerik:TimelineViewDefinition />
                </telerik:RadScheduleView.ViewDefinitions>
            </telerik:RadScheduleView>
                </StackPanel>
        </Grid>
     
    </navigation:Page>

    Note that it doesn't work for the combobox inside the EditAppointmentdialog : cmbProjects
    but it works with the same binding formula
    ItemsSource="{Binding ElementName=RecurrentScheduleView, Path=DataContext.Projets, Mode=TwoWay}"

    if the combobox is outside the RadScheduleView : cmbProjects2

    thanks by advance !
  2. Answer
    Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 22 Sep 2011 Link to this post

    Hello Maxence,

    The first way to resolve this is to bind your RadComboBox directly to the ViewModel:
    <telerik:RadComboBox x:Name="cmbProjects" ItemsSource="{Binding Source={StaticResource ViewModel}, Path=Projets, Mode=TwoWay}"/>
    As I can see your page is inheriting its DataContext. If you cannot access your ViewMiodel I would suggest you a workaround. You can attach to the Loaded event of your RadComboBox and load its items there:
    private void cmbProjects_Loaded(object sender, RoutedEventArgs e)
    {
        var viewModel = (ViewModel)this.RecurrentScheduleView.DataContext;
        var radComboBox = (RadComboBox)sender;
        radComboBox.Items.AddRange(viewModel.Projets);
    }

    Hope this helps.

    Regards,
    Ivo
    the Telerik team

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

  3. Maxence
    Maxence avatar
    21 posts
    Member since:
    Aug 2011

    Posted 22 Sep 2011 Link to this post

    Hi Ivo,

    thanks for your help !
    I take the second solution and it works nicely

    Regards,

    Maxence
Back to Top