Using WinRT library in WPF application. - c#

I have followed this article here:
http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx
And it all works great... but how do I get a preview in WPF?
The XAML "CaptureElement" control is not available in WPF. Is there any other way I can get a preview using the MediaCapture API?
Why would Microsoft not make this control Available?

Late reply, but in case that helps folks in the future: previewing MediaCapture in WPF is difficult but possible. Here is some code sample:
https://github.com/mmaitre314/MediaCaptureWPF

After investigating further it seems impossible to get this to work with the XAML Capture Element or any other XAML element in WPF.
I decided to port my WPF app to a Win8 application. I kept the existing back end code and referenced it using a Brokered WinRT Component. An excellent tutorial can be found here: http://devhawk.net/2014/04/25/brokered-winrt-components-step-one/ on how to create a WinRT brokered component.
Keep in mind that the app must be sideloaded and will not work for apps that you want to publish to the store.

You will have to rig up a mechanism to display the converted BitmapImage yourself, e.g., either in an Image control or as an ImageBrush on some surface. To the best of my knowledge, WinRT controls cannot be hosted in WPF.
CaptureElement was presumably not ported to WPF because it depends on WinRT APIs, and it makes little sense to introduce a dependency into WPF for an API that is only available on Windows 8+, and which is only officially supported in Windows Store apps.

Related

ArcGIS web map in c# winform

I want to implement an ArcGIS web map in my winform C# application. I have found a bunch of resources for doing this in a WPF application, but nothing for the winform platform. I have an API-Key from ArcGIS and have already made a webmap.
Does anyone know if this is even possible or do I need to use WPF to do this? I have tried the GMap open source, and it does support some maps from ArcGIS, but I have not figured out how to add "custom" webmaps from a link. I would also need to add credentials to my example.
F.eks
Map.MapProvider = GMap.NET.MapProviders.ArcGIS_World_Street_MapProvider.Instance;
Edit,
Sadly it seems that the best solution is to implement a wpf controller into the winform application.
You can definitely use the Esri ArcGIS Runtime SDK to do this. Yes it is a WPF control, but that's no problem. You'll need to use the ElementHost to host WPF content inside the WinForms view, and this is fully supported but the runtime. Just be aware that WinForms uses software rendering, so you don't get as good performance as you would with a pure WPF, UWP or WinUI3 window.
So you'll just follow all the doc found on how to do it in WPF, then render that part of the view inside the ElementHost of your WinForms app.
WinForms Element host doc: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.elementhost?view=net-5.0
Conceptual doc/examples of hosting WPF in WinForms:
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/walkthrough-creating-new-wpf-content-on-windows-forms-at-design-time?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-wpf-composite-control-in-windows-forms?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-3-d-wpf-composite-control-in-windows-forms?view=netframeworkdesktop-4.8
/Morten Nielsen - Dev Lead (ArcGIS Runtime SDK for .NET)
If I understand correctly you want a world map, I don't know what you're planning on doing with it so if you just want to display a world map then I found a YouTube tutorial about this that might help,
https://www.youtube.com/watch?v=TxSJJfaAzKg
If you want an interactive map and arcgis does that for you then you can emulate a WPF control inside a winforms application,
https://www.youtube.com/watch?v=VfpzVDAJ1fE
Sorry if I'm only showing YouTube videos as sources instead of actual documentation, but at least it gets the job done.

Why does the Xamarin.Forms designer not show windows layouts?

I tried searching for this everywhere, but I cannot find any solution.
I also tried looking at solution properties, project properties, visual studio preferences, Visual Studio extensions, change XAML xmlns definitions but I have no clue why this is not possible, and I think it should be standard simple functionality.
When you create a new Xamarin.Forms project that includes
, you would suspect that there is not only a way to see your XAML design on Android and iOS but also for any Windows platform you are targeting, such as W10 Desktop but also other Windows platforms that UWP supports and that supposedly Xamarin. Forms do support according to the website from Microsoft. You can easily build your project for these platforms, no problem. But I want to see what I am doing before I compile my work.
When opening your XAML design, instead of a simple Android / iOS and Windows tab in the design panel, Windows is nowhere to be found.
How am I supposed to see how my Windows screen is going to look without an option to see this? In WPF and plain UWP, this works fine, but somehow for Xamarin it only shows Android/IOS, but apparently, Xamarin has full support for Windows (desktop).
I am looking for multi-platform support to create a windows desktop application that is easily portable to iOS and Android. I thought Xamarin could do that, but if I am not able to see what I am doing on Windows in terms of layout, how am I supposed to develop a solid UI for the platform?
I am probably missing some kind of checkbox somewhere (I am hoping), but I cannot find any information about this. Yes, I tried to google. And Stack overflow. And Xamarin documentation from Microsoft. And watch YouTube videos about Xamarin for 20 minutes that supposed to explain the Xamarin multi-platform support. And after 20 minutes I find they only specifically explain iOS/Android but nothing about Windows. So yeah, getting pretty tired of searching and hope someone can be kind enough to help me out.
This is a limitation of Xamarin.Forms. Although it uses XAML, it has a custom XAML dialect which is not compatible with WPF/UWP, so the built-in UWP designer cannot handle it directly and it will require a custom designer implementation.
But if you want a first-class Windows development experience compatible with Android, iOS and even WebAssembly, try looking into the Uno Platform. This is a UWP bridge with full XAML compatibility with UWP XAML, so your app will look exactly the same on all platforms and provides full templating and styling support. In addition, Uno Platform provides bridge for many non-UI APIs as well, including things like Clipboard, Accelerometer and so on. In the end you will be able to just write a Windows app which will work everywhere with minimal changes.
You can use XAML adaptive triggers to make sure the app works well on each screen size and scales great from desktop to mobile.
If you want desktop version of you app just add UWP or WPF blank project to your solution.
For UWP it goes like this:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/windows/installation/
For WPF it goes like this:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/other/wpf
Right click on your "Project.UWP" or "Project.WPF" project and pick "Set as Startup Project"
and building your solution.

Which C# project type should I choose? Need UWP design features, but WPF functionality

I want to take advantage of the nice acrylic brush that is offered in UWP, but I also need to be able to access other process information and load DLLs for SDKs (e.g. Aura(needs dll) and Philips Hue(works without referencing dll) and detect system hibernation/wake (UWP cant't distinguish between going to the lock screen or going to hibernation or waking/logging in)).
I tried to make this in UWP, but the sandbox is making it impossible.
I also tried in WPF, but I couldn't get as good and nice performing acrylic effect as UWP offered, only the aero blur which is not as strongly blurred.
I lastly tried to create a WPF project that uses the Microsoft.Toolkit.Wpf.UI.Controls Nuget package, however it doesn't seem to come with the acrylic brush for WPF.
What are my alternatives in C#?
Is it possible to run a uwp app as the UI and have a WPF app as a constant background task without delay, messaging back and forth?
Is it possible to run a uwp app as the UI and have a WPF app as a constant background task without delay, messaging back and forth?
Yes, sort of. You can add a desktop extension component to your UWP app.
#Stefan Wick has written a number of blog posts on the subject and also provided a code sample on GitHub that shows how to extend a UWP app with a "classic" .NET console desktop application that runs as a full trust process.
Please refer to his blog for more information.
The question is asked in a kind of odd shape...
however in WPF you can achive blur effect linke this:
<Grid.Effect>
<BlurEffect Radius="4" KernelType="Gaussian"/>
</Grid.Effect>
The radius changes the "blurynes"
And no you cannot run seperate applications without any draw backs...
you should also check out:
Apply blur to everything behind a chosen container
I think you are looking for Application Packaging Project in Visual Studio. You can find the examples on MS blog: https://blogs.windows.com/buildingapps/2017/12/04/extend-desktop-application-windows-10-features-using-new-visual-studio-application-packaging-project/#KeIh8l8WoJ5OLGkE.97

Using WPF dll's in UWP app

I'm writing a UWP app, and for some reason I'm unable to reference PresentationFramework.dll. It contains some WPF controls I want to use (specifically, System.Windows.Controls.DataGrid, but they aren't available under Universal Windows >> Extensions in the reference manager. Why is this, and how can I fix it?
TL;DR: You can't use WPF controls in UWP.
WPF and UWP are two totally different APIs with a different .NET framework. While WPF has access to the full .NET Framework, UWP has a much more limited API. If you want to read more on the different platforms and compilers, this msdn blog post is a good entry point.
You are thus unable to add any standard dlls as a reference to an UWP app. If you want to share code between WPF and UWP, you'll have to use a Portable Class Library, in which you target the platforms you need.
And as the XAML namespaces for WPF and UWP are different as well, you won't find many portable controls. So for UWP development you'll need to use UWP controls (equivalent to their WPF counterparts). Bonus tip: if you're looking for 3rd party controls, you can also look for 'winrt' controls as winrt was used for Windows 8/8.1, but it's the same technology.
I know this is an old question. Not even going to research what came out when. There is a DataGrid for UWP as part of the community toolkit:
https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid
It's really frustrating though, because it doesn't seem to do a few things that the WPF version does, and these are the few things I needed it do do.
Microsoft really needs to come up with a new naming conventions for its 114 different frameworks and platforms. Controls should be named DataGridWpf, DataGridUwp, etc.
It's super hard to search for examples of the UWP DataGrid control and find thousands of examples for the WPF version. Just my two cents. And for the record, it seems like there are about 5 active links to examples on the UWP version. Arrg.
/And for added fun, Telerik and DevExpress have UWP data grid controls, which they also call DataGrids.

What options do I have on Winforms Video playback using .net 2.0

what options do I have for video playback in my .net c# windows application.
currently I am playing with "Microsoft.DirectX.AudioVideoPlayback" but this has, if I am not mistaken, a pre-requirement that DirectX be loaded on the computer.
are there any other options?
UPDATE:
I am using winforms .net 2.
Not sure what display technology you are using (WPF or WinForms), but take a look at the WPF MediaElement. It abstracts everything for you and plays really well.
If you are using WinForms, you can still embed the WPF MediaElement inside the WinForms if it makes sense for you.

Categories

Resources