change appointment property dynamically
Hi,
I try to change custom properties dynamically in AppointmentTapped event, but it doesn't work. However, if I change an original property like endTime, the changes appear!
Here is the code :
<syncfusion:TimelineViewSettings.AppointmentTemplate>
<DataTemplate>
<BorderBorderThickness="3"BorderBrush="{Binding borderBackground}"CornerRadius="5"VerticalAlignment="Stretch">
<Border.Background>
<SolidColorBrushColor="{Binding Background.Color}"/>
</Border.Background>
<StackPanel
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<TextBlockMargin="5"
Text="{Binding Name}"
Foreground="{Binding ForegroundColor}"
TextWrapping="WrapWithOverflow"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
FontStyle="Normal"
TextAlignment="Left"
FontWeight="Normal"FontSize="13"/>
</StackPanel>
</Border>
</DataTemplate>
</syncfusion:TimelineViewSettings.AppointmentTemplate>
publicclassCustomAppointment:ScheduleAppointment,INotifyPropertyChanged
{
privateString _line;
publicStringLine
{
get{return _line;}
set{ _line =value;OnPropertyChanged(Line);}
}
privateString _name;
publicStringName
{
get{return _name;}
set{ _name =value;OnPropertyChanged(Name);}
}
publiceventPropertyChangedEventHandlerPropertyChangedd;
publicvoidOnPropertyChanged(string propertyName)
{
var eventHandler =this.PropertyChangedd;
if(eventHandler !=null)
{
eventHandler(this,newPropertyChangedEventArgs(propertyName));
}
}
}
private void Schedule_AppointmentTapped(object sender, AppointmentTappedArgs e)
{
var ca= e.Appointment as CustomAppointment;
ca.Name = "Jimmy";
}
If I check property in debugging mode, the property has been changed, but not displayed !
Thanks
Jim
Hi Jim,
Based on the provided details we have reviewed your query regarding Custom properties doesn’t work dynamically in AppointmentTapped event.
Upon analysis, we noticed that you're using hardcoded property names when raising property change notifications in CustomAppointment class. Instead, we recommend using nameof() to properly trigger the property changed event, as shown in the following code snippet.
|
private String _name; public String Name { get { return _name; } set { _name = value; OnPropertyChanged(nameof(Name)); } }
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } |
If
this solution does not resolve your issue, or if you encounter any further
challenges, please provide more details so we can investigate and offer a
suitable solution.
Feel
free to reach out if you need additional help. We're here to assist you!
Regards,
Tamilarasan G.
- 1 Reply
- 2 Participants
-
TC the carpenter
- Feb 14, 2025 10:03 AM UTC
- Feb 19, 2025 05:00 PM UTC