簡體   English   中英

圖像未在listpicker wp7中顯示

[英]Image not shown in listpicker wp7

我陷入了一個問題。 我想在listpicker wp7中綁定圖像和文本數據。 但是當我將圖像和文本綁定到listpicker中時,僅文本綁定。 圖片未綁定。

這是我的代碼:

public void loadvehicaltype()
        {
            List<vehical> listofvehical = new List<vehical>();

            listofvehical.Add(new vehical() { CarType= "Any Vehical"   });
            listofvehical.Add(new vehical() { CarType = "test1", carImage = "Images/car_Images/test_yellow.png" });
            listofvehical.Add(new vehical() { CarType = "test2"   });
            listofvehical.Add(new vehical() { CarType = "Any Vehical" });


            this.listPickerVehicalType.ItemsSource = listofvehical;
        }

這是汽車課:

public class vehical
    {

        public string CarType { get; set; }
        public string carImage { get; set; }
    }

這是XAML:

 <toolkit:ListPicker x:Name="listPickerVehicalType" Tap="listPickerVehicalType_Tap" SelectionMode="Single" ItemTemplate="{StaticResource ListPickerItemTemplate}" FullModeItemTemplate="{StaticResource ListPickerFullModeItemTemplate}"   FullModeHeader="Items" CacheMode="BitmapCache"/>

<DataTemplate x:Name="ListPickerItemTemplate">

            <StackPanel Orientation="Horizontal">

                <TextBlock Text="{Binding CarType}" Margin="10 0 0 0"/>
                <!--<Image Source="{Binding carImage}" Margin="10,0,0,0" Stretch="None" />-->

            </StackPanel>

        </DataTemplate>

        <DataTemplate x:Name="ListPickerFullModeItemTemplate">

            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding CarType}" Margin="10,0,0,0"/>
                <Image Source="{Binding carImage}"  />
             </StackPanel>

        </DataTemplate>

請幫助我解決這個問題。 我搜索此問題,但未找到結果

這是因為您的映像將其生成操作設置為“資源”(這是默認設置)。 您將其切換到內容:右鍵單擊您的圖像並將其構建操作設置為內容

請點擊以下鏈接獲取更多幫助

請點擊以下鏈接獲取更多幫助

暫無
暫無

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

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