0

I am using a Telerik RadTimeline control in my project, I have a template for the TimelineItemTemplate:

<telerik:RadTimeline x:Name="myTimeline" 
                             PeriodStart="{Binding PeriodStart}"
                             PeriodEnd="{Binding PeriodEnd}"
                             VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}"
                             VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=TwoWay}"
                             StartPath="StartDate"
                             DurationPath="Duration"        
                             GroupPath="Title"
                             GroupExpandMode="Multiple"
                             ItemsSource="{Binding myData}"
                             TimelineItemTemplate="{StaticResource myTemplate}"
                             ScrollMode="ScrollOnly" 
                             IsSelectionEnabled="True" SelectionMode="Extended"
                             DataContext="{Binding ElementName=vm}">
</telerik:RadTimeline>

My template is the next:

<DataTemplate x:Key="myTemplate">
    <controls:CustomTimelineControl Style="{StaticResource myStyle}"/>
</DataTemplate>

And my style:

<Style x:Key="myStyle" TargetType="controls:CustomTimelineControl">
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="controls:CustomTimelineControl">
            <Border Height="{Binding Source={StaticResource odpSettings}, UpdateSourceTrigger=, Converter={StaticResource visibleToHeightConverter3}, ConverterParameter=Largos}" Margin="{Binding Source={StaticResource odpSettings},Path=ItemBorderMargin,Mode=OneWay}">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="largosHeatItem" Storyboard.TargetProperty="Background" Duration="0.00:00:00.05">
                                    <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0" Value="{StaticResource HeatItem_Background_MouseOver}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="largosHeatItem" Storyboard.TargetProperty="Background" Duration="0.00:00:00.05">
                                    <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0" Value="{StaticResource HeatItem_Background_MouseOver}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>

                <Border x:Name="largosHeatItem" Height="{Binding Source={StaticResource odpSettings}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource visibleToHeightConverter2}, ConverterParameter=Largos}"
                    Margin="0, 0, 0, 0" Background="{Binding DataItem.Status, Converter={StaticResource typeToColorConverter}}">
                    <TextBlock Text="{Binding DataItem.HeatId}"
                        FontFamily="Segoe UI" 
                        Foreground="{StaticResource HeatItem_Foreground}"
                        FontSize="{Binding Source={StaticResource odpSettings}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource visibleToFontSizeConverter}}"
                        Height="{Binding Source={StaticResource odpSettings}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource visibleToHeightConverter1}, ConverterParameter=Largos}"
                        TextAlignment="Center"/>
                </Border>
            </Border>
        </ControlTemplate>
    </Setter.Value>
</Setter>

I have converters for the borders height, textblock size and height, as value I am sending an object that contains several properties in order to set the correct value, for example:

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        AppSettings objSettings = value as AppSettings;
        double val = 0;

        if (parameter != null && parameter is string)
        {
            switch((string)parameter)
            {
                case "Planos":
                    if(objSettings.BothGantt)
                        val= objSettings.PlanosItemHeight1;
                    else
                        val= objSettings.PlanosItemHeightMax1;
                    break;
                case "Largos":
                     if(objSettings.BothGantt)
                        val= objSettings.LargosItemHeight1;
                    else
                        val= objSettings.LargosItemHeightMax1;

                    break;
            }
        }

        return val;
    }

opdSettings is an ObjectDataProvider:

<ObjectDataProvider x:Key="odpSettings" ObjectType="{x:Type src:AppSettings}"/>

When the application is loaded, the control is shown correctly, but then when the appication is running I need to change some properties of odpSettings that affects the Timeline layout but it doesn't show the new values.

Is there a way to "refresh" the converters binding so the control shows the changes? I tried to use UpdateSourceTrigger=PropertyChanged but it didn't work.

Or is there another way to accomplish my goal?

Thanks in advance.

Alberto

Juan Alberto
  • 165
  • 3
  • 18
  • I think it's because you're using `Source=StaticResource` in your bindings, so WPF assumes the value is static and will never change. Can you change that to a `DynamicResource` instead, and make sure it implements `INotifyPropertyChanged`? – Rachel Aug 14 '14 at 18:50
  • I am already using INotifyPropertyChanged, I tried changing to DynamicResource but I get the next error: – Juan Alberto Aug 14 '14 at 20:42
  • A DynamicResourceExtension cannot be set on the Source property of type Binding. A DynamicResourceExtension can only be set on a DependencyProperty of a DependencyObject. – Juan Alberto Aug 14 '14 at 20:44

0 Answers0