Hi,in yours WinForms Scheduling components the Appointment Class has a very useful BarColor property. I couldn't find a corresponding property in you WPF Appointment Class.
Is there a way to get the corresponding functionality, so that I can color the border of the appointment to my own desire?
If yes can someone show how?
Thanks,Roberto
Being able to assing a color to an appointment is a major necessity and, in fact, it is an important feature in your own schedule compontes for winforms.I guess that a bindable ActivityColor property in the Activity Class would do it. Having that property would allow the user to re-template this way the control templates contained in the file generic.shared.xaml
<ControlTemplate x:Key="ActivityTemplate" TargetType="igSchedulePrim:ActivityPresenter">
<Border BorderThickness="3" BorderBrush="{Binding ActivityColor}">
<Grid>
[...]
</Grid>
</Border>
</ControlTemplate>Best Regards
Hi Roberto,
You should create your own custom appointment class which has BarColor property and to use property mappings to bind it to the schedule. In the template of the ActivityPresenter you should use something like this:
BorderBrush="{Binding DataItem.BarColor}"
I attached the sample application. Hope this helps.
Thanks,
Diyan Dimitrov
Hi Diyan,
thanks to your suggestions I made it work the way I wanted. Let me point out though, in case someone else stumble in the same obstacle, that at first I was going crazy since I could not see anything but empty timeslots. After some headbanging I found the problem: since I prefer to avoid using literals in the INotifyPropertyChanged implementation I don't use:
this.RaisePropertyChanged("Description");
instead I use
NotifyPropertyChanged(descriptionChangeArgs); where descriptionChangeArgs is declared as follows. private static PropertyChangedEventArgs descriptionChangeArgs = ObservableHelper.CreateArgs<MyClass>(x => x.Description) You must have seen many of this implementations around. I inherit from a base class that implements the INotifyPropertyChanged as follows: public abstract class ViewModelBase : INotifyPropertyChanged { #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; /// <summary> /// Notify using pre-made PropertyChangedEventArgs /// </summary> /// <param name="args"></param> protected void NotifyPropertyChanged(PropertyChangedEventArgs args) { PropertyChangedEventHandler handler = PropertyChanged; String propertyName = args.PropertyName; if (handler != null) { handler(this, args); } } /// <summary> /// Notify using String property name /// </summary> protected void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } So my first attempt has been to directly implement INotifyPropertyChanged in MyAppointment Class and continuig to avoid the use of literals, without results.Finally I used your class with literals and ...it worked.Is this expected behaviour?It's not a big issue but gave me headaches for a couple of hours.Best RegardsRoberto
NotifyPropertyChanged(descriptionChangeArgs);
where descriptionChangeArgs is declared as follows.
private static PropertyChangedEventArgs descriptionChangeArgs = ObservableHelper.CreateArgs<MyClass>(x => x.Description) You must have seen many of this implementations around.
private static PropertyChangedEventArgs descriptionChangeArgs = ObservableHelper.CreateArgs<MyClass>(x => x.Description)
You must have seen many of this implementations around.
I inherit from a base class that implements the INotifyPropertyChanged as follows:
public abstract class ViewModelBase : INotifyPropertyChanged { #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; /// <summary> /// Notify using pre-made PropertyChangedEventArgs /// </summary> /// <param name="args"></param> protected void NotifyPropertyChanged(PropertyChangedEventArgs args) { PropertyChangedEventHandler handler = PropertyChanged; String propertyName = args.PropertyName; if (handler != null) { handler(this, args); } } /// <summary> /// Notify using String property name /// </summary> protected void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } So my first attempt has been to directly implement INotifyPropertyChanged in MyAppointment Class and continuig to avoid the use of literals, without results.Finally I used your class with literals and ...it worked.Is this expected behaviour?It's not a big issue but gave me headaches for a couple of hours.Best RegardsRoberto
public abstract class ViewModelBase : INotifyPropertyChanged { #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; /// <summary> /// Notify using pre-made PropertyChangedEventArgs /// </summary> /// <param name="args"></param> protected void NotifyPropertyChanged(PropertyChangedEventArgs args) { PropertyChangedEventHandler handler = PropertyChanged; String propertyName = args.PropertyName; if (handler != null) { handler(this, args); } } /// <summary> /// Notify using String property name /// </summary> protected void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion }
So my first attempt has been to directly implement INotifyPropertyChanged in MyAppointment Class and continuig to avoid the use of literals, without results.Finally I used your class with literals and ...it worked.Is this expected behaviour?It's not a big issue but gave me headaches for a couple of hours.Best RegardsRoberto
I was trying to reproduce what you are saying but I couldn’t succeed. Can you send a sample project where you are able to reproduce this behavior?
Oops...
my mistake.Must have been something else. I guess too many hours on the keyboard.
Sorry.