- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作一款游戏,我希望用户能够从右侧滑动并从 Windows 8 的 super 按钮栏中打开设置。
我已经尝试了很多东西,但我还没有设法让它发挥作用。如果有人做过,请告诉我你是怎么做到的。我正在使用 Visual Studio 2012 Express。
最佳答案
更新:
从 Windows 8.1 开始,SettingsFlyout 控件已添加到 Windows 应用商店应用程序的控件集合中。
添加 => 新建 => SettingsFlyout
然后像这样添加:
sealed partial class App
{
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
protected override void OnWindowCreated(WindowCreatedEventArgs args)
{
SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
}
private void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
var setting = new SettingsCommand("MySetting", "MySetting", handler =>
new MySettingsFlyout().Show());
args.Request.ApplicationCommands.Add(setting);
}
结果:
旧方法:
这是在 Windows 8 中使用 xaml 和 c# 实现的方法
1.创建一个xaml用户控件
<UserControl
x:Class="CSharp_Settings.Settings.Help_Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="646">
<Border BorderBrush="#FF590151" BorderThickness="1">
<Grid Background="White" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="#FFFF00F2" Grid.Row="0">
<Grid Margin="40,20,17,13">
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition FromHorizontalOffset="50" />
</TransitionCollection>
</Grid.Transitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Click="Button_Click_1" Margin="0,3,0,0" Grid.Column="0"
HorizontalAlignment="Left" Style="{StaticResource BackButtonStyle}"/>
<TextBlock Margin="10,5,0,0" Grid.Column="1" FontFamily="Segoe UI"
FontWeight="SemiLight" FontSize="24.6667" Text="Help" HorizontalAlignment="Left" />
<Image Source="/Assets/icon.png" HorizontalAlignment="Right" Grid.Column="2"
Margin="0,0,6,0" />
</Grid>
</Grid>
<Grid Grid.Row="1" Margin="40,24,23,0" VerticalAlignment="Top">
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition FromHorizontalOffset="120" />
</TransitionCollection>
</Grid.Transitions>
<TextBlock Text="Something" Foreground="Black"/>
</Grid>
</Grid>
</Border>
</UserControl>
用户控件的代码隐藏
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
namespace CSharp_Settings.Settings
{
public sealed partial class Help_Settings
{
public Help_Settings()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (Parent is Popup)
((Popup)Parent).IsOpen = false;
SettingsPane.Show();
}
}
}
在应用程序中注册设置面板
using CSharp_Settings.Settings;
using Windows.Foundation;
using Windows.UI.ApplicationSettings;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace CSharp_Settings
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
_window = Window.Current.Bounds;
Window.Current.SizeChanged += OnWindowSizeChanged;
SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested;
}
private Rect _window;
private Popup _popUp;
private const double WIDTH = 646;
private void OnWindowSizeChanged(object sender, WindowSizeChangedEventArgs e)
{
_window = Window.Current.Bounds;
}
private void CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
args.Request.ApplicationCommands.Add(new SettingsCommand("help", "Help", Handler));
}
private void Handler(IUICommand command)
{
_popUp = new Popup
{
Width = WIDTH,
Height = _window.Height,
IsLightDismissEnabled = true,
IsOpen = true
};
_popUp.Closed += OnPopupClosed;
Window.Current.Activated += OnWindowActivated;
_popUp.Child = new Help_Settings {Width = WIDTH, Height = _window.Height};
_popUp.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? (_window.Width - WIDTH) : 0);
_popUp.SetValue(Canvas.TopProperty, 0);
}
private void OnWindowActivated(object sender, WindowActivatedEventArgs e)
{
if (e.WindowActivationState == CoreWindowActivationState.Deactivated)
_popUp.IsOpen = false;
}
private void OnPopupClosed(object sender, object e)
{
Window.Current.Activated -= OnWindowActivated;
}
}
}
在 Javascript 和 html 中,您确实在 html 中创建:
<!doctype HTML>
<html>
<body>
<div style="border: 1px solid #AB00A5" data-win-control="WinJS.UI.SettingsFlyout" data-win-options="{settingsCommandId:'help', width:'narrow'}">
<div class="win-ui-dark win-header" style="background-color:#FF00F7">
<button type="button" onclick="WinJS.UI.SettingsFlyout.show()" class="win-backbutton"></button>
<div class="win-label"> Help</div>
<img src="../images/icon.png" style="position: absolute; right: 40px; width:35px; height:35px"/>
</div>
<div class="win-content win-settings-section">
<h3>Help!</h3>
<p> No help for you muahahaha</p>
</div>
</div>
</body>
</html>
Function to register the settings pane:
(function () {
"use strict";
WinJS.Application.onsettings = function (e) {
e.detail.applicationcommands = {
"about": {
title: "About",
href: "/html/settings_about.html"
},
"help": {
title: "Help",
href: "/html/settings_help.html"
}
};
WinJS.UI.SettingsFlyout.populateSettings(e);
};
WinJS.Application.start();
})();
请记住以下几点:
关于c# - Windows 8 Metro App 制作设置弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15043352/
有没有办法将 Dapper 包含在 Metro 应用程序中? 它依赖于 WinRT 中遗漏的 System.Data。 如果没有,是否有任何类似的框架可以使用? 最佳答案 Is there any w
我想为 Windows 8 Embedded Standard(发布预览版)创建一个自定义 shell(WinForms),允许用户运行、安装或更新应用程序(可以是桌面和/或 Metro 应用程序)。
我需要使用 c++ (WINRT/Metro) 在我的应用程序中生成唯一的临时文件名。如我所见,Win32 API GetTempFileName标记为仅在桌面上使用。 Metro 风格应用程序的等价
我想检索登录用户的用户名。是否可以?该应用程序仅用于内联网。 最佳答案 要将 Windows 身份验证添加到应用程序,请声明 'enterpriseAuthentication' capability
Metro UI 不支持多重绑定(bind)吗? 还是只是还没有添加? 最佳
我有公钥模数和公钥指数,我需要在 Metro 风格应用程序中生成公钥和加密数据。在 C# 中,我们有 RSAParameters 类,但我找不到任何适用于 Metro 风格应用程序的此类内容。 当我使
我从某人那里收到了一个项目,其中包括一个带有一些传感器和灯的 Arduino (Uno) 板,带有 USB 电缆以及用于通过 COM 端口与该板通信的文档化协议(protocol)。它适用于一些现有代
我正在尝试使用 Windbg 调试 C++ Metro 应用程序。由于 Windbg 在桌面上执行,应用程序在调试 session 5 秒后暂停,我必须切换回 Metro Desktop 以恢复应用程
任何人都可以建议我如何在 MahApps Metro 布局中实现图 block 的拖放。谢谢.. 最佳答案 我们使用 punker76 的另一个库取得了成功。 它轻量级且易于实现! GitHub ht
我想为我的 Android 应用程序设计 Metro 风格的 UI。怎么做?有什么捷径吗?我尝试使用 ImageView 制作一个。如何为其赋予效果?还有其他方法吗?请帮助我.... 最佳答案 试试
我看到 Metro 应用已更名为“Windows 8 应用”或“Windows 应用商店应用”。 是否有独立于通过其商店发布的工作流程的全屏应用程序风格的术语?你能构建一个可以直接安装的 Window
我正在开发一个应用程序,它将一些文件下载到本地存储进行缓存。在线文件有时位于 3 或 4 个嵌套文件夹中,我也想将此层次结构保留在我的缓存文件夹中。 除了 (await (await folder.G
我正在开发一个 Office 加载项,并想添加一个 WPF Mahapps Windows。 一切顺利,但我无法应用 Mahapps Windows 样式。 看教程here我看到我更新了 App.xa
我正在开发一个 Office 加载项,并想添加一个 WPF Mahapps Windows。 一切顺利,但我无法应用 Mahapps Windows 样式。 看教程here我看到我更新了 App.xa
如何获取Windows应用商店应用(Metro应用)中的唯一设备? 我们可以使用: Windows.System.Profile.HardwareIdentification.GetPackageSp
我正在执行 http GET 来获取数据,我正在使用 IXMLHTTPRequest2。 如果我 GET url "http://foo.com"(curl "http://foo.com") ,第二
我正在使用 Javascript 和 HTML 构建 Windows Metro 应用程序,但它崩溃了 HierarchyRequestError : Exception was thrown but
我正在创建一个简单的 metro 应用程序。我也在创建同一个应用的非 Metro 版本。 我面临的问题是 VS 不允许我将普通类库引用到 Metro 应用程序中,也不允许我将 Metro 类库引用到普
我正在尝试捆绑 markdown 文件而不产生太多开销(即不将它们手动添加到 Xcode 和 Android Studio 中的 Assets 包,不使用第 3 方依赖项)。 我的想法是允许 requ
能否在 Windows 8 上基于 C# XAML 的 Metro 应用程序中嵌入 IE Web 浏览器控件?另外,这样做时 HTML/Javascript 是否可以拥有 Windows 8 HTML
我是一名优秀的程序员,十分优秀!