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

Update TimeRulerItem when FilterFunc results change

2 Answers 94 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 29 Apr 2014, 04:28 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 30 Apr 2014, 02:01 PM
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.
 
0
Brian
Top achievements
Rank 1
answered on 30 Apr 2014, 02:36 PM
That works great! Thank you!!
Tags
ScheduleView
Asked by
Brian
Top achievements
Rank 1
Answers by
Yana
Telerik team
Brian
Top achievements
Rank 1
Share this question
or