簡體   English   中英

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 的問題

請幫幫我

謝謝你。

我在 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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM