이 자습서에 따라 Xamarin.Forms를 사용하고 있습니다 .
public MasterPage()
{
var masterPageItems = new List<MasterPageItem>();
masterPageItems.Add(new MasterPageItem
{
Title = "Contacts",
IconSource = "contacts.png",
TargetType = typeof(Pages.Contacts)
});
masterPageItems.Add(new MasterPageItem
{
Title = "ToDo",
IconSource = "todo.png",
TargetType = typeof(Pages.ToDo)
});
masterPageItems.Add(new MasterPageItem
{
Title = "Reminders",
IconSource = "reminders.png",
TargetType = typeof(Pages.Reminder)
});
masterPageItems.Add(new MasterPageItem
{
Title = "Login",
IconSource = "reminders.png",
TargetType = typeof(Pages.Login)
});
masterPageItems.Add(new MasterPageItem
{
Title = "Sign Up",
IconSource = "reminders.png",
TargetType = typeof(Pages.SignUp)
});
listView = new ListView
{
ItemsSource = masterPageItems,
ItemTemplate = new DataTemplate(() => {
var imageCell = new ImageCell();
imageCell.SetBinding(TextCell.TextProperty, "Title");
imageCell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
return imageCell;
}),
VerticalOptions = LayoutOptions.FillAndExpand,
SeparatorVisibility = SeparatorVisibility.None
};
Padding = new Thickness(0, 40, 0, 0);
Icon = "hamburger.png";
Title = "Personal Organiser";
Content = new StackLayout
{
VerticalOptions = LayoutOptions.FillAndExpand,
Children = {
listView
}
};
}
모든 icons.png (할 일, 미리 알림 등)를 MyProject.UWP 루트 내에 배치했습니다.
하지만 Visual Studio (디버그 모드, x64)에서 실행할 때 Master-Detail Page의 탐색 레이아웃 내에서 아이콘을 볼 수 없습니다.
편집 : BuildAction
이미지 속성에서 필드를 볼 수 없습니다 .
편집 2 : 이제 볼 수 있습니다. 폴더에 이미지 복사 / 붙여 넣기가 아니라 "기존 항목 추가"가 필요합니다.
BuildAction은 Content로 설정되어야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다