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

AppointmentItemBackground_Selected & Appointment background binding

4 Answers 177 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Aldo
Top achievements
Rank 2
Aldo asked on 19 Jun 2012, 11:01 AM
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



4 Answers, 1 is accepted

Sort by
0
Aldo
Top achievements
Rank 2
answered on 19 Jun 2012, 12:43 PM

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);
        }
    }
0
Aldo
Top achievements
Rank 2
answered on 20 Jun 2012, 08:40 AM
No way ?
Isn't possible ?
0
Vladi
Telerik team
answered on 20 Jun 2012, 11:36 AM
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 >>

0
Aldo
Top achievements
Rank 2
answered on 20 Jun 2012, 12:25 PM
Thanks a lot, it's perfect :)
Tags
ScheduleView
Asked by
Aldo
Top achievements
Rank 2
Answers by
Aldo
Top achievements
Rank 2
Vladi
Telerik team
Share this question
or