我在C#中的 Windows Phone 7 应用中有 Telerik RadDataBoundListbox 。我想为列表项添加项目模板。我在Visual Studio 2012中执行以下操作:
当我这样做时,我在弹出的对话框中收到错误消息“创建模板失败”。
我注意到的一件事是编辑其他模板中的无选项到编辑生成的项目(ItemTemplate)“上下文菜单,就像有一个标准列表框(非Telerik)。创建/编辑Telerik数据绑定列表框的项目模板需要做什么?
此Telerik帮助页面提供了有关创建项目模板的说明,但是通过直接XAML编辑和通过DataTemplate元素而不是ItemTemplate,但它适用于RadListBox而不是RadDataboundListBox。我想知道是否有办法直接从IDE中完成,特别是来自Expression Blend:
Telerik RadListBox Custom Item Template
下面是列表框的当前XAML。
<phone:PhoneApplicationPage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Helpers="clr-namespace:FindAPet_WP7.Helpers" xmlns:ViewModel="clr-namespace:FindAPet_WP7.ViewModel" xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
x:Class="FindAPet_WP7.Page4"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<Helpers:EnumToDescAttrConverter x:Key="EnumToDescAttrConverter"/>
<!-- <telerik:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> -->
<Helpers:BusyVisibilityConverter x:Key="BusyVisibilityConverter" />
</phone:PhoneApplicationPage.Resources>
<phone:PhoneApplicationPage.FontFamily>
<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
</phone:PhoneApplicationPage.FontFamily>
<phone:PhoneApplicationPage.FontSize>
<StaticResource ResourceKey="PhoneFontSizeNormal"/>
</phone:PhoneApplicationPage.FontSize>
<phone:PhoneApplicationPage.Foreground>
<StaticResource ResourceKey="PhoneForegroundBrush"/>
</phone:PhoneApplicationPage.Foreground>
<phone:PhoneApplicationPage.DataContext>
<ViewModel:ViewModelLocator/>
</phone:PhoneApplicationPage.DataContext>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Main.AppName, Mode=OneWay}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Choose Shelters" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="48" Height="55"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="0*"/>
<RowDefinition Height="8*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<telerikPrimitives:RadBusyIndicator
Content="Telerik Loading..."
Foreground="#FF9EC6EE"
IsRunning="True"
Opacity="0.75"
Margin="3,48,-14,5"
Visibility="{Binding Main.IsBusyLoading, Converter={StaticResource BusyVisibilityConverter}, FallbackValue=Collapsed, Mode=OneWay}" FontSize="48" Grid.RowSpan="2" d:IsHidden="True" />
<Button x:Name="btnTest" Content="Test" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,0,0,0" Height="72" Grid.Row="2" Width="129" Command="{Binding Main.DisplayMessageCommand, Mode=OneWay}"/>
<telerikPrimitives:RadDataBoundListBox x:Name="listShelters" ItemsSource="{Binding Main.ShelterList}" SelectedItem="{Binding Main.SelectedShelter.IsChecked, Mode=TwoWay}" SelectionChanged="listShelters_SelectionChanged" Visibility="{Binding Main.IsBusyLoading, ConverterParameter=true, Converter={StaticResource BusyVisibilityConverter}, Mode=OneWay}" EmptyContent="" IsCheckModeActive="True" IsCheckModeEnabled="True" ItemCheckedStateChanged="listShelters_ItemCheckedStateChanged" CheckModeDeactivatedOnBackButton="False" DisplayMemberPath="Name" LayoutUpdated="listShelters_LayoutUpdated" Loaded="listShelters_Loaded" ItemCheckedPath="IsChecked" Grid.Row="1"/>
</Grid>
</Grid>
</phone:PhoneApplicationPage>