Reputation: 6432
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)
Upvotes: 0
Views: 3701
Reputation: 1585
Infact you don't need to define ItemsSource="{Binding Items}"
in
<ListBox x:Name="MainListBox" SelectionChanged="MainListBox_SelectionChanged">
Upvotes: 0
Reputation: 6276
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.
Upvotes: 5