App.xaml.cs에 3 개의 버튼이있는 appbar를 추가하여 각 페이지에 추가하지만 다른 버튼을 추가하려는 페이지가 있습니다. .전체 appBar, 특정 페이지에 대해이 애플릿에 다른 버튼 추가
필자는 App.xaml.cs의 3 가지 기본 단추를 사용하여 appbar를 얻은 다음 다른 단추를 추가합니다. 문제는 그것이 추가되고 페이지를 변경할 때 내가 추가 한 버튼을 볼 수있게 유지하는 것입니다 ... 따라서 각 페이지가 동일한 응용 프로그램을 참조하기 때문에 객체 참조에 문제가 있습니다.
4 개의 버튼이있는 페이지에만이 appbar를 복사 할 수 있는지 궁금합니다 ... (Icloneable?하지만 어떻게 모르겠다 : /) 어떻게 생각하세요? 일부 단추는 탐색을 사용하여 다른 페이지로 이동한다는 점도 언급해야합니다.
private void BuildLocalizedApplicationBar()
{
App _app = Application.Current as App; //in my page, it's an attribute that I initialize in my constructor.
ApplicationBar = _app.AppBar; //get the appbar with 3 buttons from App.xaml.cs
// Create new buttons and set the text value to the localized string from AppResources.
ApplicationBarIconButton appBarButtonTagPlace = new ApplicationBarIconButton(new Uri("/Assets/AppBar/White/appbar.heart.outline.png", UriKind.Relative));
appBarButtonTagPlace.Text = AppResources.TagThisPlaceTitle;
appBarButtonTagPlace.Click += AppBarButtonTagPlaceOnClick;
ApplicationBar.Buttons.Add(appBarButtonTagPlace);
}
가 사전에 감사합니다
App.xaml.cs를
private ApplicationBar _appBar;
public ApplicationBar AppBar { get { return _appBar; } } //property called in other page
//Method called in the constructor
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
_appBar = new ApplicationBar();
// Create a new button and set the text value to the localized string from AppResources.
var appBarButtonScan = new ApplicationBarIconButton(new Uri("/Assets/AppBar/White/appbar.qr.png", UriKind.Relative));
appBarButtonScan.Click += AppBarButtonScanOnClick;
appBarButtonScan.Text = AppResources.Scan;
var appBarButtonSearch = new ApplicationBarIconButton(new Uri("/Assets/AppBar/White/appbar.search.png", UriKind.Relative));
appBarButtonSearch.Click += AppBarButtonSearchOnClick;
appBarButtonSearch.Text = AppResources.Search;
var appBarButtonFacebook = new ApplicationBarIconButton(new Uri("/Assets/AppBar/White/appbar.facebook.png", UriKind.Relative));
appBarButtonFacebook.Click += AppBarButtonFacebookOnClick;
appBarButtonFacebook.Text = AppResources.MyAccount;
_appBar.Buttons.Add(appBarButtonScan);
_appBar.Buttons.Add(appBarButtonSearch);
_appBar.Buttons.Add(appBarButtonFacebook);
// Create a new menu item with the localized string from AppResources.
ApplicationBarMenuItem appBarMenuSettings = new ApplicationBarMenuItem(AppResources.SettingsTitle);
_appBar.MenuItems.Add(appBarMenuSettings);
}
페이지에서 내가뿐만 아니라 하나 개의 버튼을 가지고 싶다 : 여기
내 코드입니다
고맙습니다. 작동합니다. :) – Volkan