我的Windows Phone 8.1通用应用程序中有2页.
我使用带有click事件代码的按钮从Page1 .xaml 导航到Page2 .xaml:
this.Frame.Navigate(typeof(Page2));
Run Code Online (Sandbox Code Playgroud)
当我在Page2上时,我使用硬件后退按钮,应用程序关闭,没有例外或任何事情.它只是返回到开始屏幕.
我已经在第2页尝试了以下内容:
public Page2()
{
this.InitializeComponent();
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
Frame.GoBack();
}
Run Code Online (Sandbox Code Playgroud)
据我所知,我不清楚后面的堆栈.
发生了什么,我该如何解决这个问题?
亲切的问候,尼尔斯
c# navigation windows-phone windows-phone-8.1 win-universal-app
我正在努力创建自定义Cortana命令.使用通用Windows平台应用程序注册和执行命令.(GitHub的)
例如,我已经注册了以下命令
<Command Name="ShutDown">
<ListenFor>Shut down</ListenFor>
<Navigate/>
</Command>
Run Code Online (Sandbox Code Playgroud)
在UWP应用程序中运行此功能
static async void ShutDown()
{
var dialog = new MessageDialog("This is where I would shut the computer down.");
await dialog.ShowAsync();
//System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
}
Run Code Online (Sandbox Code Playgroud)
但是在设置之后System.Diagnostics.Process,UWP不支持我学到的东西.
我想运行的自定义命令涉及某种执行,例如启动外部程序,运行其他脚本或打开网站.
UWP不支持它们是有意义的,因为它是通用的,XBox或手机可能无法做到这些,但我希望在Windows 10 PC上有一些替代或黑客的方法来实现这一点.
我有办法Process在UWP应用程序中执行命令或具有类似功能的其他东西吗?似乎即使我可以让Cortana执行我的C#代码,UWP也不支持在这种情况下有用的东西.
提前致谢.
执行异步功能以获取本地数据,访问文件或调用API时,如何在此可能的长例程中触发加载动画?
这是一个例子:
<Button onClick="Button_Click" />
public async void Button_Click(object sender, RoutedEventArgs e)
{
var myData = await MyDataManager.GetMyData();
await new MessageDiaglog("Data Loaded!").ShowAsync();
}
Run Code Online (Sandbox Code Playgroud)
由于它是一个通用商店应用程序,我认为它应该在Windows 8.1和Windows Phone 8.1中都一样.
从解决方案更新
Per igrali回答,我更新了我的代码以供将来参考:
<ProgressBar x:Name="LoadingBar" Visibility="Collapsed" IsEnabled="False" IsIndeterminate="true" Height="4" HorizontalAlignment="Stretch"/>
<Button onClick="Button_Click" />
public async void Button_Click(object sender, RoutedEventArgs e)
{
LoadingBar.IsEnabled = true;
LoadingBar.Visibility = Visibility.Visible;
var myData = await MyDataManager.GetMyData();
await new MessageDiaglog("Data Loaded!").ShowAsync();
LoadingBar.IsEnabled = false;
LoadingBar.Visibility = Visibility.Collapsed;
}
Run Code Online (Sandbox Code Playgroud)
此代码适用于手机和平板电脑.
我正在为Windows 8.1/Windows Phone 8.1编写一个通用应用程序,在某些时候会显示一个电话号码列表.我想要做的是允许用户按下这些号码中的一个并在Windows Phone 8.1上运行时让设备呼叫(或请求允许呼叫)该号码.我知道以前在Windows Phone 8中可以执行以下操作:
using Microsoft.Phone.Tasks;
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "2065550123";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();
Run Code Online (Sandbox Code Playgroud)
注意:此代码包含在#if WINDOWS_PHONE_APP中
但是,在尝试导入时Microsoft.Phone.Tasks,Visual Studio无法找到引用.我知道必须在Windows Phone 8中的WMAppManifest.xml中启用" ID_CAP_PHONEDIALER ",但通用应用程序模型似乎无法实现这一点.我一直在寻找解决方案,但找不到最新的包含Windows Phone 8.1(不是Silverlight)的解决方案.
有通过通用应用程序拨打电话的方法吗?或者目前根本不可能?
AdaptiveTrigger是否可以在DataTemplate中工作?
这是我用来自定义我的ShellNavigation的代码,除了视觉状态之外它工作得很好.它们不会触发任何东西.
<shell:ShellHeadView x:Key="ShellHeadView_01">
<shell:ShellHeadView.ContentTemplate>
<DataTemplate>
<Grid Margin="20,0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="GreenBackgroundVisualState">
<VisualState.Setters>
<Setter Target="headViewLeft.Background" Value="Green" />
</VisualState.Setters>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1000"/>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="OrangeBackgroundVisualState">
<VisualState.Setters>
<Setter Target="headViewLeft.Background" Value="Orange" />
</VisualState.Setters>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="2000"/>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="RedBackgroundVisualState">
<VisualState.Setters>
<Setter Target="headViewLeft.Background" Value="Red" />
</VisualState.Setters>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="3000"/>
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" x:Name="headViewLeft" Width="100" Height="90">
</Grid>
Run Code Online (Sandbox Code Playgroud) 我正在使用设置插件,我正在努力存储一些布尔值.现在我想添加管理DateTime对象.我在Settings.cs中添加了以下内容:
private const string TimeRemainingKey = "time_remaining";
private static readonly DateTime TimeRemainingDefault = DateTime.Now;
public static DateTime TimeRemaining
{
get
{
return AppSettings.GetValueOrDefault(TimeRemainingKey, TimeRemainingDefault);
}
set
{
AppSettings.AddOrUpdateValue(TimeRemainingKey, value);
}
}
Run Code Online (Sandbox Code Playgroud)
最初我在我的代码中使用了以下内容:
Settings.TimeRemaining = new DateTime().AddMinutes(30);
Run Code Online (Sandbox Code Playgroud)
当我添加一些日志记录时,我有这个:
DateTime dt = new DateTime();
Debug.WriteLine(dt.ToString());
dt = dt.AddMinutes(30);
Debug.WriteLine(dt.ToString());
Settings.TimeRemaining = dt;
Debug.WriteLine(Settings.TimeRemaining.ToString());
Run Code Online (Sandbox Code Playgroud)
打印出来:
1/1/0001 12:00:00 AM
1/1/0001 12:30:00 AM
1/1/0001 12:00:00 AM
为什么会出现这种情况?
我正在尝试通过制作一个提供有关口袋妖怪信息的基本应用来学习Windows Phone开发.为此,我创建了一个可移植的类库(PokeLib.dll),因此它与通用应用程序兼容.我通过同一解决方案("测试")中的项目对此进行了测试,并且工作正常.您可以在我的Github上查看这些代码,但据我所知,这一切都很好.这两个项目都在一个解决方案中.对于Windows Phone应用程序的解决方案,我将PokeLib添加为"现有项目",添加了引用,并编写了几行代码以确保我可以调用它:
MainPage.xaml中:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Name="GetDataButton" Content="GetData" Click="GetDataButton_Click" Grid.Row="0" HorizontalAlignment="Center"/>
<TextBlock Name="DataText" Text="Click to get data" Grid.Row="1" Padding="10"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
MainPage.xaml.cs中:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
p = new Pokemon(1); // gets data for Pokemon #1 (Bulbasaur)
}
Pokemon p;
int counter = 0;
private async void GetDataButton_Click(object sender, RoutedEventArgs e)
{
DataText.Text = "Fetching... Count: " + ++counter;
if (counter == 1) // first time button's clicked
{
await p.Create(); …Run Code Online (Sandbox Code Playgroud) 我想在Windows Universal Application中检查互联网连接类型.
为了提供下载大尺寸内容的选项.并且还感知重要的网络可用性变化.
目前,我只能检查互联网是否连接使用类的GetIsNetworkAvailable方法NetworkInterface.
NetworkInterface.GetIsNetworkAvailable();
Run Code Online (Sandbox Code Playgroud) 挣扎着冻结应用程序的错误,只发生在平板电脑上(从不在我的笔记本电脑上).似乎与快速切换汉堡菜单有关.我有一个堆栈跟踪,导致第三方控制,但我得到的10次中的9次是以下.只有一些"异步空白",我无法避免它们(覆盖事件)和其他日志记录,我相信问题出在XAML中(方法是记录进入/退出):
未指定的错误:System.Runtime.InteropServices.COMException(0x80004005):未指定的错误
在Oceaneering.Commons.Utilities.Logger.CoreApplication_UnhandledErrorDetected(Object sender,UnhandledErrorDetectedEventArgs e)上的Windows.ApplicationModel.Core.UnhandledError.Propagate()中出现未指定的错误
设置如下:
CoreApplication.UnhandledErrorDetected += CoreApplication_UnhandledErrorDetected;
Run Code Online (Sandbox Code Playgroud)
接收方法是:
try {
e.UnhandledError.Propagate();
}
catch (Exception ex){
logChannel.LogMessage(string.Format("Unhandled Exception: {0}:{1}", ex.Message, ex.ToString()));
SaveToFileAsync().Wait();
}
Run Code Online (Sandbox Code Playgroud)
我可以做些什么来收集更多信息?谢谢!
win-universal-app windows-10-mobile uwp windows-10-universal
我有一个按钮,我想用它来启动视频播放,所以它应该看起来像一个"播放"按钮.屏幕上的按钮相当大.这是我到目前为止:
<Button Style="{StaticResource PlayButton}">
<SymbolIcon Symbol="Play"/>
</Button>
Run Code Online (Sandbox Code Playgroud)
PlayButton资源定义MinPeight和MinWidth为200px.这个问题是播放图标非常小,大约16px左右.我怎样才能让它变大?我尝试在Button声明中设置FontSize ="200",但没有区别.
c# ×8
uwp ×3
windows-10 ×2
.net ×1
cortana ×1
navigation ×1
windows-8.1 ×1
wpf ×1
xamarin ×1
xaml ×1