0

我在 C#中的Windows Phone 7应用程序中有一个Telerik RadDataBoundListbox 。我想为列表项添加项目模板。我在 Visual Studio 2012 中执行以下操作:

  • 右键单击文档大纲中的列表框
  • 选择编辑其他模板
  • 选择编辑模板
  • 选择创建空

当我这样做时,我在弹出对话框中收到错误消息“创建模板失败”。

我注意到的一件事是在“编辑附加模板”上下文菜单中没有编辑生成的项目(ItemTemplate) ”选项,就像标准列表框(非Telerik)一样。我需要做什么来为 Telerik 数据绑定列表框创建/编辑项目模板?

此 Telerik 帮助页面提供了有关创建项目模板的说明,但通过直接 XAML 编辑和通过 DataTemplate 元素而不是 ItemTemplate,但它适用于 RadListBox 而不是 RadDataboundListBox。我想知道是否有办法直接从 IDE 中进行,尤其是从 Expression Blend:

Telerik RadListBox 自定义项目模板

下面是列表框的当前 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>
4

0 回答 0