Getting started with Windows 10 Universal Apps [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'd like to get a jump start on developing Universal Apps for Windows 10. I thought it would be fairly easy, as 1) Universal Apps are already available for Windows 8.1 and 2) Microsoft keep telling us how awesome they are. I therefore concluded there would be many good examples out there.
I was wrong.
Or: I have yet to find them.
I'm no expert, I'm just a hobby developer. I know VB.net, but have gotten into C# in the later years too. I know the basics and then some for Windows Forms, WPF, asp.net and Windows Phone apps.
I've found several tutorials and templates for Windows 8 Universal Apps (some even on Microsoft Virtual Academy). They are easy to follow and offer explanations on what is really going on and why they do certain things in a specific way. The problem is that these don't necessary work great when trying to convert an app to Windows 10.
What I need is a simple sample with:
The hamburger menu
A couple of Pages with simple navigation
A Settings page that saves the settings
(Optional) A way to save state
Everything I've found so far is either based on Windows 8.1 and can't be ported easily, or is based on Visual Studio 2015 RC or 2013, and something has changed since Windows 10 was released.
I'm used to struggle a bit when learning something new, but now it's like there's a new huge obstacle around every corner regardless of which route I take.
Any pointers? :)

You will need Visual Studio 2015 in order to build and deploy Universal Windows Platform apps, because they utilise NuGet 3.0, and with that, a different package structure. Google "Universal Windows Developer Tools" for those.
For the Navigation Manager, when I started building my UWP app, back in the Technical Preview, I copied the Navigation Helper, Relay Command and Suspension Manager from the Windows 8.1 App Template, and then removed the #IF Windows_Phone and #IF Windows(I believe those are it). Compilation statements (and their containing code For #IF Windows Phone only), although you could probably leave it in, just there is some Windows Phone BackRequested functionality baked in there that I didn't want. It does provide Save and load state functions that you build into the page, if you look into the Navigation Helper Class.
You could instead, check out Jerry Nixon's Template 10: Here, I haven't used it personally because I have already spent over 190+ Hours building my app, it would be a lot of work to switch out the Base (I have already re-written a lot from learning bindings, then x:Bind during development, and I only truly discovered how to make Events and Event Handlers and operating them throughout the app globally just the other day). Template10 is a much cleaner, and probably better Base Template for Making an App than what is provided by Visual Studio by Default.
A Sample of a SplitView APP can be seen here, it is another sample by Jerry Nixon, and it uses MVVM, which is probably a good habit/Structure to learn.
As for saving settings, use ApplicationData.Current.RoamingSettings.Values[_Your Key Here_] = _Object_;
Which serializes and stores it in your AppData as a string in a secure Dat file.
To get your object/value back all you need to do is (T)ApplicationData.Current.RoamingSettings.Values[_Your Key Here_]; T being a generic for the Type of object you want to retrieve from settings. You can learn more from MSDN, Google: "Guidelines for app data MSDN", which should provide you with helpful guides (unfortunately I can only have two links in my post).
Hope that helps

Related

Create non UWP apps in C# and XAML?

Short backstory, I need to create an App for my computing coursework, and since I'm quite the procrastinator I wanted to make an app that shuts down processes that users waste time on.
Therefore I looked up how to make Windows 10 apps and stumbled across Microsoft's own "C# Fundamentals for Absolute Beginners" and "Windows 10 Development" for absolute beginners. I spent over 20 hours watching these videos over the past few weeks.
Now I have designed nearly all the UI in XAML over the past few days and now when working on the Code behind in c# I noticed that System.Diagnostics.Process could not be found, I tried to work out why and eventually stumbled across this answer which made my jaw drop (TLDR it's because it's a UWP app): Missing reference to System.Diagnostics.Process
I do not need my app to run on the Windows Store, all it needs to run on is my computer however messy the solution may be, but I really need access to that class to shutdown processes. I really want to make the app in C# and XAML though and I'm not sure if I can do this whilst having access to the System.Diagnostics.Process class.
I am really running out of time for this project and I can't just change my idea as the problem definition essay has already been marked, etc and that would take forever to rewrite.
I am open to the idea of just writing the application fully in C# if there's really no way I can use XAML without making a UWP app. But I'm not sure what's the easiest way of doing this/what project type so any help would be appreciated.
I feel very angry at Microsoft for not making it clear that "Windows 10 Development for absolute beginners is" actually "Windows Store Development for absolute beginners". I do not want my app on the Windows Store so if I could force reference the process class that would be great!
You need to develop a Desktop app (WPF). With WPF you also use C# and XAML, however you can use all .Net Framework.
UWP (Store apps) need to run in devices like Surface RT (Windows RT), Lumia 920 (Windows 10 Mobile), XBOX and Hololens so they use only a part of the full .Net Framework (they use the .Net Core Framework). UWPs run in a sandboxing so they usually don't have access to system APIs (low level access like create a IP package). In this case you should use WPF.
Your problem is one of the reason, I think that StackOverflow use the tag uwps and win-universal-app.

Windows Phone Silverlight/Xaml Which one i choose for developing my application [duplicate]

When I create new Windows Phone project I have an option to create a "Windows Phone" or "Windows Phone Silverlight" app. I know that they have different runtimes and different APIs.
I was under the impression that Microsoft wants to unify Windows and Windows Phone platforms so why is there even a Silverlight version? What benefits does it bring?
Also, if I want to create an app just for Windows Phone and never have plans to bring it to Windows, what should I choose, Silverlight or Windows Phone?
I'd suggest you go with "Windows Phone" (non-Silverlight). It's the new API, which works for both Windows and Windows Phone. At some point you may want to port the app or create a new one for Windows and you'll already know the API (and porting will be way easier). Also, the new API will most likely get more updates and features added, and at some point you may even be forced to update to it (either because the old one is no longer supported, or because it does not have some features that you need).
As it was said in the other answers - the Silverlight option is there only for backward compatibility and is likely to be phased out in time. That is - it's good if you already know the API and have many libraries (yours or others) for WP Silverlight, but if you're just starting - you'd better go for the new technology.
Edit
There is one other thing to consider before choosing between the two types of apps. Some features are only available in a Silverlight app, and others (smaller amount) - only in a Xaml app. Here's an article with some info on the differences: Migrating your Windows Phone 8 app to a Windows Runtime XAML app
Windows RT Xaml is quite new and People have to generate some knowledge first.
Silverlight for phone has been around for years and there's a load of tools available: Phone Toolkit, diverse Controls, etc.
Just killing it off would have hurt many developers who built up intellectual property over a long time forcing them to start over.
When starting a project with Silverlight you will have more things around that help you get stuff done.
When starting with WinRT Xaml, you will have better performance, but will have to figure a lot out by yourself.
So the Silverlight option is there to not throw of Silverlight developers.
I recently started a new project on WinRT Xaml and my experience was that I had to recreate a lot of common tools like Caches, etc. But also a lot of things that were in Toolkits previously are now part of the platform itself. Also, when moving over to Windows 8, you get to share a lot of code which is nice.
Unifying the environment(s) would be ideal. In my opinion, it hasn't been very successful. At one point in time, you could only develop under Silverlight, so what you are seeing is just a newer version of the same thing to keep backwards compatibility as well as to keep Silverlight's developers happy. In the future, it will probably be phased out. Plus if you want to support older Phones, Silverlight is basically your only choice (you'll be surprise, how many WP users haven't updated their 8.0 to 8.1)
There really isn't any other real benefit of Silverlight other than maybe the Windows Phone Toolkit which has been tremendously useful (you can see how many SO's answers rely on this simple addon). Once the universal runtime gets fleshed out to the point where the documentation reflects what's actually available -- then I think it would be the default project for developing in Windows going forward.
If you're just starting, I would use Silverlight the knowledge based is much greater. After you get use to the WP environment then switch to runtime.

Possible to launch an application in the "Metro" environment and desktop environment? - Windows 8/8.1

Ok, so I'm a major amature to the world of programing and I want to make an app that can be deployed through the Windows Store. This is mainly because it seems easier and cheaper than if I were to distribute it myself. I'm using Visual Studio Ultimate 2013 (hooray for free college software!) and I plan on using c# and JSON to pull some data from a public api.
My question is: If I develop an app so that it can be downloaded and installed from the Windows Store to be primarily be used in "Metro" mode, can I also add a button that makes it switch over to desktop mode like Google Chrome has?
Note: I have done some research on the subject and I think this is doable, but I could never find specifics on how it's done. I appreciate any insight you can provide!
AFAIK, as of Windows 8.1 there is no built-in support in WSA to run in a window on the desktop, unless you find that Snap mode suits your needs (it does for me). Primary browser is an exception, but it's not strictly just a WSA.
However, there are 3rd party solutions to do precisely that, e.g. ModernMix, so technically it's possible, but goes outside of what you have access to during WSA development.
There are also talks about Windows 8.2 supporting this out of the box: dailytech

Windows 8 DirectX SwapChainBackgroundPanel Questions

I come from two distinct backgrounds: I have much experience with WPF/XAML/C# app development and equal experience with C++/DirectX development. I hear about the ability to use DirectX and XAML together and I get all excited, but now I have hit this wall.
I'm trying to use the SwapChainBackgroundPanel in a WPF application. But I'm trying to use C# as the underlying language. I keep running into issues where, regardless of the type of C# project I create (PCL, WPF, Windows Store) none of these types are defined [namely I've been looking for SwapChainBackgroundPanel and some other DX stuff like the device and etc.)
So my question is: how does this work in C#? I've seen the simple shooter example from the MSDN done in C++ and it makes sense; I get it. But I feel like I'm missing one of those "gotcha's" when trying to do it in C#.
Any advice, or maybe a link to an example, or at best a little tutorial on setting up a C#/XAML/DX app would be amazing. Thanks everyone.
There is no SwapChainBackgroundPanel available to a WPF app (that is in PresentationCore). The closest you are going to get is the D3DImage class, but it's not exactly the same. See this discussion.
I don't think you can fully utilize the DirectX capabilities of a Windows 8 Store app (SwapChainBackgroundPanel) from C#. You're going to have to do your DirectX work in C++ as in the example you described. You can certainly combine the three (Xaml, C#, C++) as in this example, but I don't think a 100% C# app is possible.
The answer is wrong. It is possible to fully utilize C# throught a wrapper.
I did this myself with SharpDx which is actually one of the microsoft recommendations to use DirectX in C#.
As for the choice of XAML Library, Universal Windows App 10 or Windows Store App 8 is the way to go. Use a SwapChainPanel instead of SwapChainBackgroundPanel.

Building C#/.NET Apps that Use Windows 7 TaskBar Features

The new Windows 7 taskbar features, like jump lists, previews, etc. are really cool, and I want to allow my C# applications to use them. I have two questions:
First of all, how can I use these functions (in general)? I found two articles by Microsoft about this, but I'm not really sure what to do. Could you provide links to a library, as well as some sample code?
Next, let's say that I figure out how to use these Taskbar functions. My question is, is there some built-in way of checking whether the OS is Windows 7, and thus enabling the taskbar functions? If I didn't have this logic in my app, would it have problems if it was run on a non-Win7 machine?
Thanks!
In the first article you link to there is a sample library that you can download that makes use of the new Windows 7 features.
This article shows how to check the version of Windows your application is running on.
As always, if you call an API that isn't in existence, then yes, your app will experience some turbulence. Remember, it's (almost) always better to check for a condition and act accordingly once (as in application startup) than to try something over and over in code and catch exceptions.
Windows API Code Pack for .NET Framework is your one stop shop for a ton of .NET API for Windows programming, including Taskbar. This library gives you a complete API set to work with Windows 7 Taskbar and then some. It also includes samples for WPF, and Winform.
Another good source for Windows 7 content is the Windows Team Blog

Categories

Resources