Windows phone 7 Windows Phone 7 Wrappanel可见性

Windows phone 7 Windows Phone 7 Wrappanel可见性,windows-phone-7,wrappanel,Windows Phone 7,Wrappanel,我有一个以gridview样式显示一组图像的列表,下面是我的代码: <controls:PanoramaItem x:Name="Pano_Photos" Header="photos"> <ListBox x:Name="lstMemoriesPhoto" ItemsSource="{Binding MemoryList}"> <i:Interaction.Triggers> <i

我有一个以gridview样式显示一组图像的列表,下面是我的代码:

<controls:PanoramaItem x:Name="Pano_Photos" Header="photos">
        <ListBox x:Name="lstMemoriesPhoto" ItemsSource="{Binding MemoryList}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged" x:Name="ListPhotoSelectionChangedEventTrigger">
                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding NavigateToDetailPage}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel ItemWidth="130" ItemHeight="130" Visibility="{Binding MemoryPhoto,Converter={StaticResource PhotoConverter}}"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding MemoryPhoto,Converter={StaticResource ByteImageConverter}}" Margin="5"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>        
    </controls:PanoramaItem>
但是当我运行我的应用程序时,我得到了这个结果,。第二个网格应该不可见,因为它包含null image变量

有人知道如何禁用wrappanel中的单个项目吗?非常感谢

编辑 我想我找到了解决问题的方法,在图像控制中定义宽度和高度,而不是在wrappanel中,代码是

<ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding MemoryPhoto,Converter={StaticResource ByteImageConverter}}" Margin="5" Visibility="{Binding MemoryPhoto,Converter={StaticResource PhotoConverter}}" width="130" height="130"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>

首先请修复转换器: 然后修复您的XAML

首先请修复转换器: 然后修复您的XAML


如果我更改为。一切都很好。如果我换成。一切都很好。您的代码生成的结果与我的问题帖子中显示的图像相同。第二个网格没有显示任何内容,但我想要的是,上面没有图像的网格应该是不可见的。似乎只要设置了ItemWidth,WrapPanel就会忽略所包含项目的Visibility属性。您的代码生成的结果与我的问题帖子中显示的图像相同。第二个网格没有显示任何内容,但我想要的是,上面没有图像的网格应该是不可见的。
<ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding MemoryPhoto,Converter={StaticResource ByteImageConverter}}" Margin="5" Visibility="{Binding MemoryPhoto,Converter={StaticResource PhotoConverter}}" width="130" height="130"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
public class PhotoConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        try
        {
            if ((value is byte[]) && (value != null))
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }

        catch (Exception ex)
        {
            throw ex;
            return Visibility.Collapsed;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
<controls:PanoramaItem x:Name="Pano_Photos" Header="photos">
    <ListBox x:Name="lstMemoriesPhoto" ItemsSource="{Binding MemoryList}">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="SelectionChanged" x:Name="ListPhotoSelectionChangedEventTrigger">
                <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding NavigateToDetailPage}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel ItemWidth="130" ItemHeight="130"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Image Source="{Binding MemoryPhoto,Converter={StaticResource ByteImageConverter}}" Visibility="{Binding MemoryPhoto, Converter={StaticResource PhotoConverter}}" Margin="5"/>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>        
</controls:PanoramaItem>