AppointmentItemBackground_Selected & Appointment background binding

5 posts, 0 answers
  1. Aldo
    Aldo avatar
    39 posts
    Member since:
    Feb 2011

    Posted 19 Jun 2012 Link to this post

    Hi,
    I need to bind some properties (background color) of my appointments to special fields added.

    So, this is my extended Appointment class (inherits Appointment)
    public class AppointmentExt : Appointment
    {
        public planning_slot Slot { get; set; }
        public string SpecialTooltip { get; set; }
        public Color SpecialForecolor { get; set; }
    }

    This is my schedule XAML

    <telerik:RadScheduleView x:Name="rsvCalendar" FirstVisibleTime="09:00" telerik:StyleManager.Theme="Metro" Grid.Column="1" Grid.ColumnSpan="2" Margin="8" Grid.Row="1" FirstDayOfWeek="Monday" Background="#BFFFFFFF" BorderBrush="#BFD6D4D4" Foreground="#BF767676" IsInlineEditingEnabled="False" AppointmentCreating="rsvCalendar_AppointmentCreating" AppointmentDeleting="rsvCalendar_AppointmentDeleting" AppointmentEditing="rsvCalendar_AppointmentEditing" ShowDialog="rsvCalendar_ShowDialog" AllowDrop="False" VisibleRangeChanged="rsvCalendar_VisibleRangeChanged" ToolTipTemplate="{DynamicResource ScheduleTooltip}" AppointmentStyleSelector="{DynamicResource AppointmentItemStyleSelector}">
                <telerik:RadScheduleView.ViewDefinitions>
                    <telerik:DayViewDefinition MajorTickLength="1h" MinorTickLength="1h" MinTimeRulerExtent="200" MaxTimeRulerExtent="500" DayStartTime="07:00" DayEndTime="19:00"/>
                    <telerik:WeekViewDefinition MajorTickLength="1h" MinorTickLength="1h" MinTimeRulerExtent="200" MaxTimeRulerExtent="500" DayStartTime="07:00" DayEndTime="19:00"/>
                    <telerik:MonthViewDefinition/>
                    <telerik:TimelineViewDefinition/>
                </telerik:RadScheduleView.ViewDefinitions>
            </telerik:RadScheduleView>

    this is from my dictionary.xaml

    <SolidColorBrush x:Key="AppointmentItemBackground_Selected" Color="???"/>
    <Style x:Key="AppointmentItemBaseStyle" TargetType="local:AppointmentItem">
            <Setter Property="Background" Value="???" />

    How can I bind ??? to SpecialForecolor properties of my AppointmentExt class ?

    Thanks

    p.s: SpecialTooltip is binded and worked fine



  2. Aldo
    Aldo avatar
    39 posts
    Member since:
    Feb 2011

    Posted 19 Jun 2012 Link to this post

    sorry, this is my extended Appontment class

    public class AppointmentExt : Appointment
        {
            private planning_slot m_slot;
            public planning_slot Slot
            {
                get
                {
                    return(this.Storage<AppointmentExt>().m_slot);
                }
     
                set
                {
                    var storage = this.Storage<AppointmentExt>();
                    storage.m_slot = value;
                    this.OnPropertyChanged(() => this.Slot);
                }
            }
     
            private string m_specialTooltip;
            public string SpecialTooltip
            {
                get
                {
                    return(this.Storage<AppointmentExt>().m_specialTooltip);
                }
     
                set
                {
                    var storage = this.Storage<AppointmentExt>();
                    storage.m_specialTooltip = value;
                    this.OnPropertyChanged(() => this.SpecialTooltip);
                }
            }
     
            private Color m_specialForecolor;
            public Color SpecialForecolor
            {
                get
                {
                    return(this.Storage<AppointmentExt>().m_specialForecolor);
                }
     
                set
                {
                    var storage = this.Storage<AppointmentExt>();
                    storage.m_specialForecolor = value;
                    this.OnPropertyChanged(() => this.SpecialForecolor);
                }
     
            }
     
            public override IAppointment Copy()
            {
                var newAppointment = new AppointmentExt();
                newAppointment.CopyFrom(this);
                return newAppointment;
            }
     
            public override void CopyFrom(IAppointment other)
            {
                var app = other as AppointmentExt;
                if (app != null)
                {
                    this.Slot = app.Slot;
                    this.SpecialTooltip = app.SpecialTooltip;
                    this.SpecialForecolor = app.SpecialForecolor;
                }
                base.CopyFrom(other);
            }
        }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Aldo
    Aldo avatar
    39 posts
    Member since:
    Feb 2011

    Posted 20 Jun 2012 Link to this post

    No way ?
    Isn't possible ?
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 20 Jun 2012 Link to this post

    Hi Aldo,

    Thank you for contacting us.

    First you need to bind the custom Background property via the Appointment property in the AppointmentItemBaseStyle style. Here is a simple code representing that:
    <Style x:Key="AppointmentItemBaseStyle" TargetType="local:AppointmentItem">
        ...
        <Setter Property="Background" Value="{Binding Appointment.SpecialForecolor}" />
        ...
    </Style>

    Also note that the Background property takes variables of SolidColorBrush type and you need to change your custom SpecialForecolor property to be of that type. Here is a simple code representing that:
    private SolidColorBrush m_specialForecolor;
     
    public SolidColorBrush SpecialForecolor
    {
        get
        {
            return (this.Storage<AppointmentExt>().m_specialForecolor);
        }
     
        set
        {
            var storage = this.Storage<AppointmentExt>();
            storage.m_specialForecolor = value;
            this.OnPropertyChanged(() => this.SpecialForecolor);
        }
    }

    Hope this helps.

    Regards,
    Vladi
    the Telerik team

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

  6. Aldo
    Aldo avatar
    39 posts
    Member since:
    Feb 2011

    Posted 20 Jun 2012 Link to this post

    Thanks a lot, it's perfect :)
Back to Top
UI for WPF is Visual Studio 2017 Ready