【发布时间】:2016-05-13 18:54:25
【问题描述】:
我创建了一个 AutocompleteBox,它在 ControlTemplate 之外完全可以正常工作。当我将它放在 Control 模板中时,自动完成框不再填充任何项目。
<ControlTemplate x:Key="EditAppointmentTemplate" TargetType="telerik:SchedulerDialog">
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="97" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Participants" Margin="6 0" VerticalAlignment="Center" HorizontalAlignment="Left" />
<telerik:RadAutoCompleteBox Margin="6 0"
Grid.Column="1"
ItemsSource="{Binding Atts}"
SelectedItems="{Binding SelectedAttendees,Mode=TwoWay}"
DisplayMemberPath="DisplayName"
TextSearchPath="Search"
Style="{StaticResource MultiAutoBox}"
WatermarkContent="Search ..."
MinHeight="55" VerticalContentAlignment="Top" Padding="5">
</telerik:RadAutoCompleteBox>
</Grid>
</ControlTemplate>
<Style x:Key="EditAppointmentDialogStyle" TargetType="telerik:SchedulerDialog">
....
<Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}" />
....
<Style x:Key="EditAppointmentDialogStyle"/>
<telerik:RadScheduleView x:Name="scheduleview" ....
EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}"
....
<telerik:RadScheduleView x:Name="scheduleview"/>
我想我必须将 ItemsSource 设置为以相对祖先为目标 我尝试了以下方法,但 itemsource 仍然没有填充。
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:SchedulerDialog}}, Path=Atts}"
【问题讨论】: