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

Tooltip Not Updating When Resources Change

1 Answer 107 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 18 May 2011, 11:08 AM

In ScheduleView I use a Tooltip template with a couple of converters to show the “Staff” and “Company” resources when someone hovers over the appointment.

If I update the Resource in the appointment the tooltip still shows the original resource not the new value, the converter doesn’t get triggered.

I assume this is a binding problem with the Appointment.Resources collection?

Is this by design? If so is there a workaround?

Tooltip:

<DataTemplate x:Key="ToolTipTemplate">
      <StackPanel>
          <TextBlock FontWeight="Bold" FontSize="12" Text="{Binding Appointment.Subject}"/>
          <TextBlock Text="{Binding Category, Mode=OneWay, Converter={StaticResource ScheduleCategoryConverter}}"/>
          <StackPanel Orientation="Horizontal">
              <TextBlock Text="Staff: "/>
              <TextBlock Text="{Binding Appointment.Resources, Mode=OneWay, Converter={StaticResource ScheduleResourceStaffConverter}}"/>
          </StackPanel>
          <StackPanel Orientation="Horizontal">
              <TextBlock Text="Company: "/>
              <TextBlock Text="{Binding Appointment.Resources, Mode=OneWay, Converter={StaticResource ScheduleResourceCompanyConverter}}"/>
          </StackPanel>
          <StackPanel Orientation="Horizontal">
              <TextBlock Text="{Binding Appointment.Start, Mode=OneWay, StringFormat=h:mm tt}"/>
              <TextBlock Text=" - "/>
              <TextBlock Text="{Binding Appointment.End, Mode=OneWay, StringFormat=h:mm tt}"/>
          </StackPanel>
      </StackPanel>
  </DataTemplate>

Converter:

 

public class ScheduleResourceCompanyConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          string strToRet = "None";
          if (value != null)
          {
              ResourceCollection Res = (ResourceCollection)value;
              foreach (Resource res in Res)
              {
                  if (res.ResourceType == "Company") strToRet = res.DisplayName;
              }
          }
          return strToRet;
      }
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          return null;
      }
  }

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 20 May 2011, 01:33 PM
Hello Michael,

When you bind to Appointment.Resources the binding will change only when Appointment raise PropertyChanged event for Resources property. But this never happens because Resources is collection property and is read only (e.g. standard pattern for implementing ICollection properties).

One possible solution is to change the TextBlock to ItemsControl and bind ItemsSource to Appointment.Resources and then to specify ItemTemplate and use converters.

Another approach will be to extend the Appointment class and add handler to Resources CollectionChanged event and when CollectionChanged is fired to raise PropertyChanged with Resource property.

I hope that this will help you.

All the best,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ScheduleView
Asked by
Michael
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or