Update TimeRulerItem when FilterFunc results change

3 posts, 1 answers
  1. Brian
    Brian avatar
    12 posts
    Member since:
    Feb 2014

    Posted 29 Apr 2014 Link to this post

    I've added a "CapacityBar" to the TimeRulerItem as seen in the attached image. The text and progress bar are supposed to show how full each day is based on the currently displayed appointments. As seen in the image, this does currently work the first time the view is displayed. When the user makes a change that causes the AppointmentFilter to show different appointments, the capacity bar is not updated.

    Here's how I added the capacity bar:
    <telerikScheduleView:TimeRulerItemTemplateSelector.MonthItemTemplate>
        <DataTemplate>
            <DataTemplate.Resources>
                <converters:DateToCapacityBarCountConverter x:Key="DateToCapacityBarCountConverter" />
                <converters:DateToCapacityBarPercentConverter x:Key="DateToCapacityBarPercentConverter" />
                <converters:DateToCapacityBarVisibleConverter x:Key="DateToCapacityBarVisibleConverter" />
            </DataTemplate.Resources>
            <Grid Margin="6 2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="{Binding FormattedValue}" Grid.Row="0" Grid.Column="0"/>
                <Grid Margin="6 2" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="1" >
                    <Grid.Visibility>
                        <MultiBinding Converter="{StaticResource DateToCapacityBarVisibleConverter}">
                            <Binding Path="DateTime" Mode="OneWay"/>
                            <Binding Path="DataContext" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadScheduleView}}" />
                        </MultiBinding>
                    </Grid.Visibility>
                    <telerik:RadProgressBar Minimum="0" Maximum="100">
                        <telerik:RadProgressBar.Value>
                            <MultiBinding Converter="{StaticResource DateToCapacityBarPercentConverter}">
                                <Binding Path="DateTime" Mode="OneWay"/>
                                <Binding Path="DataContext" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadScheduleView}}" UpdateSourceTrigger="PropertyChanged" />
                            </MultiBinding>
                        </telerik:RadProgressBar.Value>
                    </telerik:RadProgressBar>
                    <TextBlock Margin="0" HorizontalAlignment="Center">
                        <TextBlock.Text>
                            <MultiBinding Converter="{StaticResource DateToCapacityBarCountConverter}">
                                <Binding Path="DateTime" />
                                <Binding Path="DataContext" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadScheduleView}}" UpdateSourceTrigger="PropertyChanged" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </Grid>
            </Grid>
        </DataTemplate>
    </telerikScheduleView:TimeRulerItemTemplateSelector.MonthItemTemplate>


    How can I get the capacity bar to refresh? I've tried doing an OnPropertyChange(null) in my ViewModel to get all properties to update, but since this doesn't really seem bound to any specific property directly, that doesn't work. Is there a better way of doing this binding? How can I get this to work the way I'd like?

    I'm sorry if this is a general WPF binding question instead of specific to telerik, but it had enough telerik details that I didn't think it was appropriate for a generic WPF forum.

    Thank you!



  2. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 30 Apr 2014 Link to this post

    Hi Brian,

    I would suggest that you create an additional bool property in the ViewModel and update it when an appointment is edited/created/deleted. Then add this property to the MultiBinding, so that the converter to be fired with each change. I have attached a sample application based on your code to demonstrate the described approach, please download it and give it a try.

    I hope this helps.

    Regards,
    Yana
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Brian
    Brian avatar
    12 posts
    Member since:
    Feb 2014

    Posted 30 Apr 2014 in reply to Yana Link to this post

    That works great! Thank you!!
Back to Top