EditAppointmentDialogStyle and Catigories

1 posts, 0 answers
  1. Zhenya Popkin
    Zhenya Popkin avatar
    1 posts
    Member since:
    May 2010

    Posted 12 Jul 2012 Link to this post

    Hi,
    I am trying create a custom DialogWindow with my catigories. But When the window opening Combobox categories is clear.
    My code is main window is
    namespace Calendar
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            AppintmentViewModel main;
     
            public MainWindow()
            {
                InitializeComponent();
                main = new AppintmentViewModel();
                this.DataContext = main;
            }
        }
     
     
        internal class AppintmentViewModel : BaseViewModel
        {
            private ObservableCollection<Category> _Categories;
            ObservableCollection<Task> _Appointments;
     
            public AppintmentViewModel()
            {
                _Appointments = new ObservableCollection<Task>()
                {
     
                    new Task(){Subject="April",Start =DateTime.Today,End =DateTime.Today.AddHours(4)},
                };
                _Categories = new ObservableCollection<Category>()
                {
     
                    new Category(){ CategoryBrush= Brushes.Red, CategoryName="Red"},
                    new Category(){CategoryBrush= Brushes.Blue, CategoryName="Blue"}
                };
            }
            public ObservableCollection<Task> Appointments
            {
                get
                {
                    return _Appointments;
                }
                set
                {
                    _Appointments = value;
                    OnPropertyChanged("Appointments");
                }
            }
     
            public ObservableCollection<Category> Categories
            {
                get
                {
                    return _Categories;
                }
                set
                {
                    _Categories = value;
                    OnPropertyChanged("Categories");
                }
            }
     
        }
     
        public class Task : Appointment
        {
             
            public override IAppointment Copy()
            {
     
                var newAppointment = new Task();
     
                newAppointment.CopyFrom(this);
     
                return newAppointment;
     
            }
     
     
     
            public override void CopyFrom(IAppointment other)
            {
     
                var task = other as Task;
     
                base.CopyFrom(other);
     
            }
        }
    }

    and XAML

    <Window x:Class="Calendar.MainWindow"
            xmlns:schedule="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"
            xmlns:scheduleView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <ControlTemplate x:Key="EditAppointmentTemplate" TargetType="scheduleView:SchedulerDialog">
                <Grid IsSharedSizeScope="True">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
     
                    <telerik:RadToolBar x:Name="AppointmentToolbar"  BorderThickness="0 0 0 1" FocusManager.IsFocusScope="False"
                     GripVisibility="Collapsed" Grid.Row="0" Margin="-1 0 -1 3">
                        <telerik:RadButton x:Name="EditRecurrenceButton" Command="scheduleView:RadScheduleViewCommands.EditRecurrenceRule">
                            <ToolTipService.ToolTip>
                                <ToolTip telerik:LocalizationManager.ResourceKey="EditRecurrence"  />
                            </ToolTipService.ToolTip>
                            <TextBlock Margin="6 0" telerik:LocalizationManager.ResourceKey="EditRecurrence" />
                        </telerik:RadButton>
                        <telerik:RadToolBarSeparator />
                        <telerik:RadComboBox x:Name="PART_Categories" Margin="2 1" Width="130"  ItemsSource="{Binding ElementName=ScheduleView, Path=CategoriesSource}" DisplayMemberPath="{Binding CategoryName}" />
     
                    </telerik:RadToolBar>
                </Grid>
            </ControlTemplate>
            <Style x:Key="EditAppointmentDialogStyle" TargetType="scheduleView:SchedulerDialog">
                <Setter Property="Width" Value="560" />
                <Setter Property="IsTabStop" Value="False" />
     
                <Setter Property="SnapsToDevicePixels" Value="True" />
     
                <Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}" />
            </Style>
            
        </Window.Resources>
        <Grid>
            <telerik:RadScheduleView AppointmentsSource="{Binding Appointments}" EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}"
                                          FirstVisibleTime="12:00" x:Name="ScheduleView" CategoriesSource="{Binding Categories}"
                                          ActiveViewDefinitionIndex="1">
                <telerik:RadScheduleView.ViewDefinitions>
                    <telerik:DayViewDefinition />
                    <telerik:WeekViewDefinition />
                    <telerik:MonthViewDefinition />
                    <telerik:TimelineViewDefinition DayStartTime="00:00" />
                </telerik:RadScheduleView.ViewDefinitions>
            </telerik:RadScheduleView>
        </Grid>
    </Window>


    If I removeEditAppointmentDialogStyle, I see mian Catigories. Can you help me?
    Thank's
     
Back to Top