2016-12-16 11 views
0

は、私は自分のページを作成するには、このコードを持っていますが、何らかの理由で画像OSがページ全体を取り、他のコンテンツ のいずれかが表示されないここで私は取得しています何の絵があります。画像は、デフォルトTEXTCOLORはあなたの背景色の見えないような黒であるのでstacklayout画面全体が追い越されていますか?

http://imgur.com/a/3qB9F

namespace GarageSale.Views 
{ 
public class abcChapterPage : basePage 
{ 
myDataTypes.abcChapter abc; 

StackLayout baseStack; 

#region Views 
Label lblName = new Label 
{ 
    Text = "", 
    VerticalOptions = LayoutOptions.StartAndExpand, 
    HorizontalOptions = LayoutOptions.CenterAndExpand 
}; 

Label lblSchool = new Label 
{ 
    Text = "", 
    VerticalOptions = LayoutOptions.StartAndExpand, 
    HorizontalOptions = LayoutOptions.CenterAndExpand 
}; 

Label lblLocation = new Label 
{ 
    Text = "", 
    VerticalOptions = LayoutOptions.CenterAndExpand, 
    HorizontalOptions = LayoutOptions.CenterAndExpand 
}; 

Image profImg = new Image 
{ 
    Scale = .1f, 
    Aspect = Aspect.AspectFit, 

}; 

Button viewItems = new Button 
{ 
    Text = " View Items ", 
    BorderRadius = 0, 
    //Margin = 0, 
    HorizontalOptions = LayoutOptions.FillAndExpand, 
}; 

Button viewMembers = new Button 
{ 
    Text = "View Members", 
    BorderRadius = 0, 
    //Margin = 0, 
    HorizontalOptions = LayoutOptions.FillAndExpand, 
}; 

#endregion 

public abcChapterPage(myDataTypes.abcChapter o) 
{ 
    abc = o; 

    populateProfileFields(); 

} 

public abcChapterPage() 
{ 
    shouldGetChapter = true; 
    abcid = int.Parse(App.CredManager.GetAccountValue("abc_chapter_id")); 
} 

StackLayout makeGUI() 
{ 
    viewItems.Command = new Command(() => 
    { 
     Navigation.PushAsync(new viewListPage(new itemListView(), abc.id, 1, "Items for sale by " + abc.school)); 
    }); 

    viewMembers.Command = new Command(() => 
    { 
     Navigation.PushAsync(new viewListPage(new userListView(), abc.id, 2, " abc Members " + abc.school)); 
    }); 



    #region basestack 
    return new StackLayout 
    { 
     VerticalOptions = LayoutOptions.Fill, 
     HorizontalOptions = LayoutOptions.Fill, 
     Children = { 
      //lblName, 
      profImg, 
      lblSchool, 
      lblLocation, 
      new StackLayout { 
       Orientation = StackOrientation.Horizontal, 
       Padding = 0, 
       // Margin = 0, 
       Spacing = 0, 
       Children = { 
        viewItems, 
        viewMembers 
       } 
      } 
     } 
    }; 
    #endregion 

} 

public void populateProfileFields() 
{ 
    baseStack = makeGUI(); 
    Title = abc.school + " abc"; 
    lblSchool.Text = abc.school; 
    lblLocation.Text = abc.city +", "+ abc.state; 

    profImg.Source = ImageSource.FromStream(() => new MemoryStream(abc.picture)); 

    Content = baseStack; 
    //TODO: do this if user is admin 
    //if (Constants.AdminUsers.Contains(App.CredManager.GetAccountValue("G_id")) && !adminAlert) 
    //{ 
    // await Task.Delay(5000); 
    // DisplayAlert("Admin Notice:", "You are logged in as an administrative user!", "Dismiss"); 
    // adminAlert = true; 
    //} 

} 

bool shouldGetChapter = false; 
int abcid; 

protected async override void OnAppearing() 
{ 
    if (shouldGetChapter) 
    { 
     abc = await App.MANAGER.YSSI.GetabcChapter(abcid); 
     populateProfileFields(); 
    } 
} 

}

+0

使用XAMLと利用できるXAMLのプレビューアツールであなたの人生を容易にします – BraveHeart

答えて

0

の内部にある画像にもかかわらず、他のすべてのコンテンツの上に産みます。 イメージが中心になるのはScale = .1f,なので、それを削除する必要があります。

0

Xamarin.FormsでAspectの使用を誤解する可能性があります。画像コントロールは、縦横比を保持せずにコンテナを塗りつぶしたり、画像を切り抜いたり、レターボックス化したりします。サイズ変更されず、画像の縦横比が保持されます。あなたのケースでは

、あなたのイメージのコンテナは、全体StackLayoutので、画像は他のコントロールをカバーしています。あなたは、画像のサイズを変更したい場合は、多くの方法は、画像ソース自体を変更するほかに、ここで最も簡単な方法は、画像制御への固定サイズを設定する必要があります、ありますが、あなたが作成したい場合は、ほとんどの異なるサイズのレイアウトを適応させますデバイスの、このシナリオでは、私がXamarin.Forms.Gridを置くことを提案し、そしてそれをRowDefinitionsColumnDefinitionsを設定します。

関連する問題