0

So, what I am trying to do here is to change the appearance of my RadScheduleView GroupHeaderContentTemplate on the click of a CheckBox. This CheckBox is bound to the ShowPictures property in my viewmodel. There is also a GroupHeaderHeight property to set the max height of each grouping.

Properties are defined below:

private bool _ShowPictures;
public bool ShowPictures    
{
    get
    {
        return this._ShowPictures;
    }
    set
    {
        if (this._ShowPictures == value)
        {
            return;
        }               
        this._ShowPictures = value;
        this.RaisePropertyChanged(nameof(this.ShowPictures));               
    }
}

private int _GroupHeaderHeight;
public int GroupHeaderHeight
{
    get
    {
        return this._GroupHeaderHeight;
    }
    set
    {
        if (this._GroupHeaderHeight == value)
        {
            return;
        }

        this._GroupHeaderHeight = value;
        this.RaisePropertyChanged(nameof(this.GroupHeaderHeight));                               
    }
}

CheckBoxs code:

<CheckBox Name="cbShowPictures" Content="Show Pictures" Grid.Column="9"
    IsChecked="{Binding ShowPictures,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

My RadScheduleViews code:

<UserControl.Resources>

<converters:DatabindingDebugConverter x:Key="DatabindingDebugConverter"/>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>

<telerik:RadScheduleView x:Name="MainSchedule" 
    Grid.Row="0" 
    Margin="2" 
    TimeMarkersSource="{Binding TimeMarkers}"
    CategoriesSource="{Binding Categories}"  
    MinAppointmentHeight="25" 
    NavigationHeaderVisibility="Visible" 
    AppointmentsSource="{Binding WorkOrderTasks,Mode=TwoWay,    UpdateSourceTrigger=PropertyChanged}" 
    AppointmentCreated="MainSchedule_AppointmentCreated"
    ResourceTypesSource="{Binding ResourceTypes}" 
    AppointmentDeleted="MainSchedule_AppointmentDeleted" 
    AppointmentEdited="MainSchedule_AppointmentEdited"
    CurrentDate="{Binding FilterStart,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
    SelectedAppointment="{Binding SelectedWorkOrderTask, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
    FirstVisibleTime="8:00:00" 
    ShowAppointmentDeleteButton="False"
    ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}">

        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:TimelineViewDefinition MinTimeRulerExtent="1" 
                MaxTimeRulerExtent="Infinity"
                MinorTickLength="1h" 
                DayStartTime="{Binding DailyStartTime, Mode=TwoWay}"
                DayEndTime="{Binding DailyEndTime, Mode=TwoWay}"
                VisibleDays="{Binding VisibleDays, Mode=TwoWay}"                                                                        
                StretchGroupHeaders="True"
                StretchAppointments="True"/>

        <telerik:DayViewDefinition  DayStartTime="{Binding DailyStartTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                DayEndTime="{Binding DailyEndTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                VisibleDays="{Binding VisibleDays, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"                                                                   
                StretchGroupHeaders="False"
                MinTimeRulerExtent="1" 
                MaxTimeRulerExtent="Infinity"
                MinorTickLength="1h" />

         <telerik:WeekViewDefinition  DayStartTime="{Binding DailyStartTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                DayEndTime="{Binding DailyEndTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                VisibleDays="{Binding VisibleDays, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"                                                                   
                StretchGroupHeaders="False"
                MinTimeRulerExtent="1" 
                MaxTimeRulerExtent="Infinity"
                MinorTickLength="1h"/>

            <telerik:MonthViewDefinition  DayStartTime="{Binding DailyStartTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
               DayEndTime="{Binding DailyEndTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
               VisibleDays="{Binding VisibleDays, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"                                                                   
               StretchGroupHeaders="False"
               MinTimeRulerExtent="1" 
               MaxTimeRulerExtent="Infinity"/>

            <telerik:CustomViewDefinition  DayStartTime="{Binding DailyStartTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
               DayEndTime="{Binding DailyEndTime, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
               VisibleDays="{Binding VisibleDays, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"                                                                   
               StretchGroupHeaders="False"
               MinTimeRulerExtent="1" 
               MaxTimeRulerExtent="Infinity"
               MinorTickLength="1h"/>

        </telerik:RadScheduleView.ViewDefinitions>
        <telerik:RadScheduleView.ActiveViewDefinition>
                <telerik:TimelineViewDefinition MinTimeRulerExtent="1" 
                                                MaxTimeRulerExtent="Infinity"
                                                MinorTickLength="1h" 
                                                DayStartTime="{Binding DailyStartTime, Mode=TwoWay}"
                                                DayEndTime="{Binding DailyEndTime, Mode=TwoWay}"
                                                VisibleDays="{Binding VisibleDays, Mode=TwoWay}"                                                                        
                                                StretchGroupHeaders="False"
                                                StretchAppointments="False"/>
        </telerik:RadScheduleView.ActiveViewDefinition>

        <telerik:RadScheduleView.AppointmentItemContentTemplate>
            <DataTemplate>
                <StackPanel Margin="4 2" MinHeight="20" >
                    <TextBlock Text="{Binding Subject}" FontWeight="Bold" />
                    <TextBlock Text="{Binding Appointment.Body}" TextWrapping="Wrap" />
                    <TextBlock Text="Time Range" Foreground="{StaticResource StrongBrush}"/>
                    <StackPanel Orientation="Horizontal" Margin="4 0">
                        <TextBlock Text="{Binding Path=Start, StringFormat='MMM dd, yyyy HH:MM'}"
                        FontWeight="SemiBold" Foreground="{StaticResource AccentBrush}" />
                        <TextBlock Text=" - " Foreground="{StaticResource AccentBrush}" />
                        <TextBlock Text="{Binding Path=End, StringFormat='MMM dd, yyyy HH:MM'}"
                        FontWeight="SemiBold" Foreground="{StaticResource AccentBrush}" />
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </telerik:RadScheduleView.AppointmentItemContentTemplate>

        <telerik:RadScheduleView.GroupDescriptionsSource>
            <telerik:GroupDescriptionCollection>
                <schedule:ResourceGroupDescription ResourceType="Equipment" />
            </telerik:GroupDescriptionCollection>
        </telerik:RadScheduleView.GroupDescriptionsSource>
        <telerik:RadScheduleView.GroupHeaderContentTemplate>
            <DataTemplate>
                <Border Background="{Binding Name.Brush}" Width="140" Height="{Binding GroupHeaderHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="1 1 1 0">
                    <StackPanel Margin="10 10 10 10">
                        <Image  Margin="5 0 10 0" Height="60" Width="60" Visibility="{Binding ShowPictures, Converter= {StaticResource BoolToVis}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                HorizontalAlignment="Left" Stretch="UniformToFill" Source="{Binding Name.Photo}" />
                        <TextBlock Text="{Binding FormattedName}" TextWrapping="Wrap"  Margin="8 0" VerticalAlignment="Center" />
                    </StackPanel>
                </Border>                                      
            </DataTemplate>
        </telerik:RadScheduleView.GroupHeaderContentTemplate>
        <telerik:RadScheduleView.TimeRulerItemStyleSelector>
            <local:GroupItemStyleSelector>

                <local:GroupItemStyleSelector.GroupItemStyle>
                    <Style TargetType="telerik:TimeRulerGroupItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="telerik:TimeRulerGroupItem">
                                    <Border BorderBrush="{StaticResource BasicBrush}" BorderThickness="1 1 0 0">
                                        <ContentPresenter Margin="4 2" />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </local:GroupItemStyleSelector.GroupItemStyle>

            </local:GroupItemStyleSelector>
        </telerik:RadScheduleView.TimeRulerItemStyleSelector>
    </telerik:RadScheduleView>

I initialize ShowPictures to true and GroupHeaderHeight to 60 in my viewmodels constructor. Getter and setters are called but no changes happen visually. The goal here is when show pictures is enabled I show the image in the group header template and increase the height, while disabled I do not show the image and lessen the height.

Please, any advice on how I could improve or errors I'm making with this could will be appreciated.

If any code is missing, I will add if asked.

Drag and Drop
  • 2,672
  • 3
  • 25
  • 37
Ruaan Volschenk
  • 717
  • 2
  • 11
  • 23
  • The problem must be similar to the DataGrid Columns Binding issue. See [my answer](http://stackoverflow.com/a/42086700/5615980) and the provided link. – rmojab63 Feb 08 '17 at 11:16

1 Answers1

1

I guess the ShowPictures and GroupHeaderHeight properties are defined in the same class as the TimeMarkers, Categories, etc. properties and then you should use a RelativeSource to be able to bind to them from the GroupHeaderContentTemplate:

<DataTemplate>
    <Border Background="{Binding Name.Brush}" Width="140" Height="{Binding DataContext.GroupHeaderHeight, RelativeSource={RelativeSource AncestorType=telerik:RadScheduleView}}" Margin="1 1 1 0">
        <StackPanel Margin="10 10 10 10">
            <Image  Margin="5 0 10 0" Height="60" Width="60" Visibility="{Binding DataContext.ShowPictures, Converter={StaticResource BoolToVis}, RelativeSource={RelativeSource AncestorType=telerik:RadScheduleView}}" 
                                HorizontalAlignment="Left" Stretch="UniformToFill" Source="{Binding Name.Photo}" />
            <TextBlock Text="{Binding FormattedName}" TextWrapping="Wrap"  Margin="8 0" VerticalAlignment="Center" />
        </StackPanel>
    </Border>
</DataTemplate>
mm8
  • 163,881
  • 10
  • 57
  • 88
  • Images hide/show is a success, but the height of the template is only changed when radscheduleview is rebound to its source. I need to change it dynamically... Thanks for your reply mm8 – Ruaan Volschenk Feb 09 '17 at 07:37
  • It increases the height when image is set to visible again, but it doesn't decrease the height after the image is collapsed – Ruaan Volschenk Feb 09 '17 at 07:44