我想关闭然后重新启动已经运行的应用程序(自动),通过单击按钮或类似的东西,我想这样做是为了用其他语言重新启动应用程序,我是一般来说是JavaFx和Java的新手,请问您能为我解决这个问题吗?
我正在使用这个Windows应用商店应用程序,我希望它支持Open With当最终用户想要使用此应用程序打开文件时,我将支持的格式添加到应用程序清单文件中的声明部分,如下图所示:

我在App.xaml.cs文件中覆盖了OnFileActivated事件,如下所示:
protected override void OnFileActivated(FileActivatedEventArgs args)
{
if (args.Files.Count > 1)
{
MessageDialog messageDialog1 = new MessageDialog("DirectTouchPlayer can't open many files, the first file will be opened.");
messageDialog1.ShowAsync();
}
OpenedMediaFile = (StorageFile)args.Files.First();
MessageDialog messageDialog2 = new MessageDialog(OpenedMediaFile.Path + " " + " : Opened !");
messageDialog2.ShowAsync();
}
Run Code Online (Sandbox Code Playgroud)
当我在.MP4文件上执行OpenWith时,此事件似乎没有触发,应用程序午餐但无法退出启动屏幕,我尝试调试事件,如此线程 解释但调试器不会停止在标记的任何断点处在OnFileActivated方法中,我感谢您的帮助.
更新1: 当一个文件上的OpenWith,然后该应用程序不能完全启动画面,我现在有这个消息框错误

更新2:
我将我的OnFileActivated事件处理程序更改为:
protected override async void OnFileActivated(FileActivatedEventArgs args)
{
var loadMediaFileTask = new Task<IStorageItem>(() =>
{
return args.Files.First();
});
OpenedFile = await loadMediaFileTask;
}
Run Code Online (Sandbox Code Playgroud)
其中OpenedFile是:
public …Run Code Online (Sandbox Code Playgroud) 根据我读到的内容,我不清楚某些事情:
Field Initializers 在构造函数之前运行.Static field Initializers在调用之前执行static constructor(仍与第1点兼容).field Initializers将在使用的类型之前执行(据我所知:没有实例化,而是被使用)这个例子解释了:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Foo.X);
Console.ReadLine();
}
}
class Foo
{
public static Foo Instance = new Foo();
public static int X = 3;
Foo()
{
Console.WriteLine("In constructor: " + X);
}
}
Run Code Online (Sandbox Code Playgroud)
此代码打印0,然后3!怎么可能呢?当我们通过Foo.X使用Foo时,会在构造函数之前调用两个第一个初始化器(到目前为止还可以),
public static Foo Instance = new Foo();
Run Code Online (Sandbox Code Playgroud)
执行它应该在调用构造函数(第1点)之前运行它自己的2个初始化程序,而它首先运行构造函数并打印X作为默认值为0.
我不能真正遵循这个逻辑,请向我澄清.
编辑:我期望发生的事情:
我有代码将 TexBox 的文本设置为
textBox1.Text = s;
Run Code Online (Sandbox Code Playgroud)
其中s是一个超过 100,000 个字符的字符串,并且在 textBox 上显示文本需要很长时间。
有人有办法让它更快吗?
我ResourceDictionary在一个单独的文件中有一个MainSkin.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="RoundedButton">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Viewbox>
<Grid>
<Grid Name="backgroundGrid" Width="80" Height="80" Visibility="Visible">
<Path Data="Some Data Path here" Stretch="Fill" Fill="#FFFFFFFF" Name="Stroke" Visibility="Visible" />
</Grid>
<Path Data="Some Data Path here" Stretch="Uniform" Fill="#FFF9F9F9" Width="44" Height="44" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<TransformGroup.Children>
<RotateTransform Angle="0" />
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup.Children>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
而我把这个资源字典中MergedDictionaries的App.Xaml Application.Resources如下:
<Application.Resources>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
<-- …Run Code Online (Sandbox Code Playgroud) 当使用任何类型的XAML基础技术进行开发时,
有没有办法Design在 VisualStudio 中使用shortcut命令甚至命令在XAML 和模式之间快速切换Command Window?

我有一种情况需要在对象初始化程序中分配一些对象的属性.其中一些对象可以为null,我需要访问它们的属性,问题是它们太多了,使用if/else的东西并不好.
例
visits = visitJoins.AsEnumerable().Select(joined => new VisitPDV()
{
VisiteId = joined.Visite.VisiteId.ToString(),
NomPointDeVente = joined.VisitePdvProduit.PointDeVente.NomPointDeVente,
});
Run Code Online (Sandbox Code Playgroud)
在joined.VisitePdvProduit可以为空,而问题是,有像几十个这样的任务的(我只是把一个缩短的代码)
C# 6 Null-Conditional operator对于这种情况来说,这是完美的解决方案,问题是我C# 5在这个项目中,有没有办法模仿呢?
第一次使用SQLite,选择了SQLite.net-pcl,
我有一个PCL库,我从我的UWP应用程序中消耗,我的PCL库有DBContext类:
public NewspaperDataContext(ISQLitePlatform sqLitePlatform, string applicationPath, string dataBaseName)
{
_sqlConnection = new SQLiteAsyncConnection(()=> new SQLiteConnectionWithLock(sqLitePlatform,
new SQLite.Net.SQLiteConnectionString(Path.Combine(applicationPath, dataBaseName), storeDateTimeAsTicks: false)));
CreateTableAsync(_sqlConnection, typeof(Article)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Author)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Category)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Group)).Result.Wait();
var c = _sqlConnection.Table<Article>();
}
private async Task<Task> CreateTableAsync(SQLiteAsyncConnection asyncConnection, Type table)
{
return asyncConnection.CreateTableAsync<Author>().ContinueWith((results) =>
{
Debug.WriteLine(!results.IsFaulted
? $"Error where creating the {nameof(table)} table !!"
: $"Table {nameof(table)} created sucessfully!");
});
}
Run Code Online (Sandbox Code Playgroud)
我NewspaperDataContext从我的UWP应用程序中调用这样的:
private async void MainPage_OnLoaded(object sender, …Run Code Online (Sandbox Code Playgroud) c# sqlite portable-class-library sqlite-net win-universal-app
如何在UWP中将BitmapImage对象转换为字节数组?在.Net中很容易实现,即使在以前的WinRT版本中,看起来遍布互联网但没有成功,其中一个解决方案是使用WriteableBitmap这个答案中提到的类似,但在当前版本的UWP中,构建一个WriteableBitmap一个BitmapImage是不可能的,任何解决方法?
c# ×7
.net ×4
wpf ×2
xaml ×2
bitmapimage ×1
c#-5.0 ×1
c#-6.0 ×1
constructor ×1
eclipse ×1
fxml ×1
initializer ×1
java ×1
javafx ×1
javafx-2 ×1
performance ×1
sqlite ×1
sqlite-net ×1
string ×1
textbox ×1
winrt-xaml ×1