WIndows Phone 7 - ListViewItem 类问题

发布于 2024-09-17 01:12:44 字数 1457 浏览 7 评论 0原文

我有一个使用 WP7 开发人员 CTP 工具开发的应用程序。现在我尝试在 WP7 beta 工具上运行相同的应用程序。

我已按照 Microsoft 发行说明

它提到了 ListViewListViewItem 类已从 Microsoft.Phone.Controls 命名空间中删除。

以下是根据发行说明的(修改后的)XML 命名空间。

xmlns:mpc="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

我有以下使用 ListView 的行。

<mpc:ListViewItem Layout="TextAndDetailsWithIcon" Text="{Binding Title.Text}" Details="{Binding Title.Text}" Style="{StaticResource PhoneListBoxItemLayout}"/>

所以(显然)它给了我关于命名空间问题的错误。 我该如何修复它?


UPDATE1 -

我直接在 DataTemplate 中定义了列表项的布局,

<TextBlock x:Name="ItemText" Text="{Binding Title.Text}" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>

现在我收到有关某些自动生成的文件 App.g.cs 中的以下行的错误>

System.Windows.Application.LoadComponent(this, new System.Uri("/RssReader;component/App.xaml", System.UriKind.Relative));

错误是

Invalid attribute value mpc:ListViewItem for property TargetType

现在问题是什么?

(注:我是Silverlight的初学者,所以请多多包涵)

I have an app which was developed using WP7 developer CTP tools.Now I'm trying to run the same app but on WP7 beta tools.

I have made all the changes needed for the above conversion as per Microsoft Release Notes

It has mentioned that ListView and ListViewItem classes are removed from Microsoft.Phone.Controls namespace.

Following is the (modified) XML namespace as per the release notes.

xmlns:mpc="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

And I have followling line in which ListView is used.

<mpc:ListViewItem Layout="TextAndDetailsWithIcon" Text="{Binding Title.Text}" Details="{Binding Title.Text}" Style="{StaticResource PhoneListBoxItemLayout}"/>

So (obviously) its giving me error about the namespace issue.
How do I fix it?


UPDATE1 -

I defined the layout of our list item directly in the DataTemplate as

<TextBlock x:Name="ItemText" Text="{Binding Title.Text}" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>

Now I'm getting an error about following line which is inside some auto generated file App.g.cs

System.Windows.Application.LoadComponent(this, new System.Uri("/RssReader;component/App.xaml", System.UriKind.Relative));

And the error is

Invalid attribute value mpc:ListViewItem for property TargetType

What seems to be the problem now?

(Note : I'm a beginner in Silverlight, So please bear)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Spring初心 2024-09-24 01:12:44

看来他们确实根据这个 链接

好吧,预定义的 ListViewItem 模板不再存在,因此我们直接在 DataTemplate 中定义列表项的布局,如下所示:

    <ListBox x:Name="MainListBox" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal">
                    <Image x:Name="ItemImage" Source="/WindowsPhoneListApplication1;component/Images/ArrowImg.png" Height="43" Width="43" VerticalAlignment="Top" Margin="10,0,20,0"/>
                    <StackPanel>
                        <TextBlock x:Name="ItemText" Text="{Binding LineOne}" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                        <TextBlock x:Name="DetailsText" Text="{Binding LineTwo}" Margin="0,-6,0,3" Style="{StaticResource PhoneTextSubtleStyle}"/>
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

当您创建默认的 WindowsPhoneListApplication 时,如果您需要完整的示例,它也会执行此布局。

It does appear that they removed that class according to this link.

Well, the predefined ListViewItem templates are no more, so instead we define the layout of our list item directly in the DataTemplate, as follows:

    <ListBox x:Name="MainListBox" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal">
                    <Image x:Name="ItemImage" Source="/WindowsPhoneListApplication1;component/Images/ArrowImg.png" Height="43" Width="43" VerticalAlignment="Top" Margin="10,0,20,0"/>
                    <StackPanel>
                        <TextBlock x:Name="ItemText" Text="{Binding LineOne}" Margin="-2,-13,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                        <TextBlock x:Name="DetailsText" Text="{Binding LineTwo}" Margin="0,-6,0,3" Style="{StaticResource PhoneTextSubtleStyle}"/>
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

When you create a default WindowsPhoneListApplication it also does this layout if you need a full example.

满地尘埃落定 2024-09-24 01:12:44

事实上,您不需要

中定义 ItemsSource="{Binding Items}"

Infact you don't need to define ItemsSource="{Binding Items}"

in

<ListBox x:Name="MainListBox" SelectionChanged="MainListBox_SelectionChanged">

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文