簡體   English   中英

無法在xamarin.forms中添加圖片。

[英]Unable to add a picture in xamarin.forms.

Image codeImage = new Image
            {
                Source = "code.jpg",
                Aspect = Aspect.AspectFit,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions = LayoutOptions.Fill
            };
            StackLayout stackLayout = new StackLayout
            {
                Children =
                {
                    codeImage
                },
                HeightRequest = 1500
            };

我將圖像放在項目的默認位置。 我什至嘗試右鍵單擊要添加的項目,然后制作一個新的默認圖像,然后將該圖像替換為我要使用的圖像。 地獄,我嘗試只使用默認圖像,該默認圖像是在將新圖像添加到繪畫中繪制幾條彎曲的線條,然后再次嘗試且仍然沒有的情況下生成的。

您需要像這樣將其添加到“內容”中:

Image codeImage = new Image
{
    Source = "code.jpg",
    Aspect = Aspect.AspectFit,
    HorizontalOptions = LayoutOptions.End,
    VerticalOptions = LayoutOptions.Fill
};
StackLayout stackLayout = new StackLayout
{
    Children =
    {
        codeImage
    },
    HeightRequest = 1500
};
// If the above isn't working in itself, this will help as final closure:
Content = stackLayout;

暫無
暫無

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

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