C# WPF TELERIK RADSCHEDULEVIEW组标题内容模板绑定
因此,我在这里试图做的是在单击复选框时更改RadScheduleView GroupHeaderContentTemplate的外观。此复选框绑定到我的viewmodel中的ShowPictures属性。还有一个GroupHeaderHeight属性用于设置每个分组的最大高度 属性定义如下:C# WPF TELERIK RADSCHEDULEVIEW组标题内容模板绑定,c#,wpf,templates,telerik,radscheduleview,C#,Wpf,Templates,Telerik,Radscheduleview,因此,我在这里试图做的是在单击复选框时更改RadScheduleView GroupHeaderContentTemplate的外观。此复选框绑定到我的viewmodel中的ShowPictures属性。还有一个GroupHeaderHeight属性用于设置每个分组的最大高度 属性定义如下: private bool _ShowPictures; public bool ShowPictures { get { return this._ShowPictu
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));
}
}
复选框代码:
<CheckBox Name="cbShowPictures" Content="Show Pictures" Grid.Column="9"
IsChecked="{Binding ShowPictures,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
我的RadScheduleViews代码:
<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>
在viewmodels构造函数中,我将ShowPictures初始化为true,将GroupHeaderHeight初始化为60。调用Getter和setter,但在视觉上不会发生任何更改。
这里的目标是当启用“显示图片”时,我在组标题模板中显示图像并增加高度,而禁用时,我不显示图像并降低高度
请,任何关于我如何改进或犯错误的建议都将不胜感激
如果缺少任何代码,我会在询问时添加。我猜ShowPictures和GroupHeaderHeight属性与Timemarker、Categories等属性定义在同一个类中,然后您应该使用相对资源,以便能够从GroupHeaderContentTemplate绑定到它们:
该问题必须类似于DataGrid列绑定问题。请参阅和提供的链接。Images hide/show成功,但模板的高度仅在radscheduleview恢复到其源时更改。我需要动态地改变它。。。感谢您的回复MM8当图像再次设置为可见时,它会增加高度,但在图像折叠后不会降低高度
<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>