0
,我的AppBar遇到很多重複代碼。除了登錄頁面之外,我的所有頁面都支持相同的AppBar。有什麼辦法來抽象的XAML代碼,還有xaml.cs代碼(例如,在點擊UI元素的修改)在我的當前C#WinRT MvvmLight應用程序中,在城市應用程序中創建一個常見的AppBar
除了登錄的頁面的XAML頁面:
<Page.TopAppBar>
<AppBar>
<!-- content here -->
</AppBar>
</Page.TopAppBar>
<Page.BottomAppBar>
<AppBar>
<!-- content here -->
</AppBar>
</Page.BottomAppBar>
任何xaml.cs除了登錄頁面頁面:
private void UserLogout_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
//First we need to find out how big our window is, so we can center to it.
CoreWindow currentWindow = Window.Current.CoreWindow;
//Set our background rectangle to fill the entire window
rectBackgroundHide.Height = currentWindow.Bounds.Height;
rectBackgroundHide.Width = currentWindow.Bounds.Width;
rectBackgroundHide.Margin = new Thickness(0, 0, 0, 0);
//Make sure the background is visible
rectBackgroundHide.Visibility = Windows.UI.Xaml.Visibility.Visible;
//Now we figure out where the center of the screen is, and we
//move the popup to that location.
popupLogout.HorizontalOffset = (currentWindow.Bounds.Width/2) - (400/2);
popupLogout.VerticalOffset = (currentWindow.Bounds.Height/2) - (150/2);
popupLogout.IsOpen = true;
}
@theStig:我的答案可以幫到你嗎? –