LongListSelector 数据绑定问题
LongListSelector Data Binding Issue
我是 windows Windows phone 编程的初学者。
我正在尝试实现 LongListSelector 以按产品显示组。
这是我的 类 :
public class ProductMaster {
public string Name { get; set; }
public List<ProductSubMaster> Models { get; set; }
}
public class ProductSubMaster
{
public string Name { get; set; }
public ProductSubMasterProperty modelProperty { get; set; }
}
public class ProductSubMasterProperty{
public string ProNo { get; set; }
public Uri ProImage { get; set; }
}
和我的 xaml :
<phone:LongListSelector
x:Name="ProductList"
ItemsSource="{Binding objProduct}"
Background="Transparent"
LayoutMode="List"
IsGroupingEnabled="True"
HideEmptyGroups ="False">
<phone:LongListSelector.GroupHeaderTemplate>
<DataTemplate>
<Border Background="Transparent" Padding="5">
<Border Background="Black" BorderBrush="Black" BorderThickness="2" Width="500"
Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding Path=[0].Name}" Foreground="White" FontSize="25" Padding="10"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
</phone:LongListSelector.GroupHeaderTemplate>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="searchimg" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Source="{Binding Path=Models.modelProperty.ProImage}" Height="100" Width="100" ></Image>
<TextBlock x:Name="ProductName" Margin="20,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" TextWrapping="Wrap" Foreground="Black" Text="{Binding Path=Models.Name}" FontSize="30"></TextBlock>
<Image x:Name="bookmarkimg" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Center" Source="/Assets/Media/star.png" Height="40" Width="30" Stretch="Uniform" ></Image>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
我遇到了绑定 ItemTemplate 的问题
请帮帮我
谢谢。
我在项目模板中添加了列表框解决了我的问题
这是我更新后的代码
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<ListBox x:Name="LstFeaturesData" Visibility="Visible" ItemsSource="{Binding Path=Models}" Margin="0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="searchimg" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Source="{Binding Path=modelProperty.ProImage}" Height="100" Width="100" ></Image>
<TextBlock x:Name="ProductName" Margin="20,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" TextWrapping="Wrap" Foreground="Black" Text="{Binding Path=Name}" FontSize="30"></TextBlock>
<Image x:Name="bookmarkimg" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Center" Source="/Assets/Media/star.png" Height="40" Width="30" Stretch="Uniform" ></Image>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
我是 windows Windows phone 编程的初学者。 我正在尝试实现 LongListSelector 以按产品显示组。
这是我的 类 :
public class ProductMaster {
public string Name { get; set; }
public List<ProductSubMaster> Models { get; set; }
}
public class ProductSubMaster
{
public string Name { get; set; }
public ProductSubMasterProperty modelProperty { get; set; }
}
public class ProductSubMasterProperty{
public string ProNo { get; set; }
public Uri ProImage { get; set; }
}
和我的 xaml :
<phone:LongListSelector
x:Name="ProductList"
ItemsSource="{Binding objProduct}"
Background="Transparent"
LayoutMode="List"
IsGroupingEnabled="True"
HideEmptyGroups ="False">
<phone:LongListSelector.GroupHeaderTemplate>
<DataTemplate>
<Border Background="Transparent" Padding="5">
<Border Background="Black" BorderBrush="Black" BorderThickness="2" Width="500"
Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding Path=[0].Name}" Foreground="White" FontSize="25" Padding="10"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
</phone:LongListSelector.GroupHeaderTemplate>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="searchimg" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Source="{Binding Path=Models.modelProperty.ProImage}" Height="100" Width="100" ></Image>
<TextBlock x:Name="ProductName" Margin="20,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" TextWrapping="Wrap" Foreground="Black" Text="{Binding Path=Models.Name}" FontSize="30"></TextBlock>
<Image x:Name="bookmarkimg" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Center" Source="/Assets/Media/star.png" Height="40" Width="30" Stretch="Uniform" ></Image>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
我遇到了绑定 ItemTemplate 的问题
请帮帮我
谢谢。
我在项目模板中添加了列表框解决了我的问题
这是我更新后的代码
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<ListBox x:Name="LstFeaturesData" Visibility="Visible" ItemsSource="{Binding Path=Models}" Margin="0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="searchimg" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Source="{Binding Path=modelProperty.ProImage}" Height="100" Width="100" ></Image>
<TextBlock x:Name="ProductName" Margin="20,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" TextWrapping="Wrap" Foreground="Black" Text="{Binding Path=Name}" FontSize="30"></TextBlock>
<Image x:Name="bookmarkimg" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Center" Source="/Assets/Media/star.png" Height="40" Width="30" Stretch="Uniform" ></Image>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>