![]() ![]() Hope you found this information helpful and maybe you can use it in one of your projects as well.Random Rectangles in Silverlight (using WriteableBitmap) Will share the actual use case in an upcoming post. I will now continue working on my actual personal app project that triggered the idea for this post. If you ever need to add a utility window to your UWP app that is chromeless and/or has an arbitrary shape – or using any of the other rich windowing capabilities that are still missing in UWP, using a desktop extension with a WPF window is a way to accomplish the scenario. This.Clip = geo closeButton.SetValue(Canvas.LeftProperty, / 2 - 16) ĬloseButton.SetValue(Canvas.TopProperty, / 2 - 16) PolyLineSegment segment = new PolyLineSegment() įor (int i = 0 i < rawPoints.Length / 2 i+=2) Root.Background = brush double rawPoints = (double) įigure.StartPoint = new Point(rawPoints, rawPoints) This.MouseMove += MainWindow_MouseMove RadialGradientBrush brush = new RadialGradientBrush() ī(new GradientStop(GetRandomColor(), 0.0d)) ī(new GradientStop(GetRandomColor(), 0.5d)) ī(new GradientStop(GetRandomColor(), 1.0d)) This.Height = (double) InitializeComponent() Again, most of the code here is specific to the sample dealing with complex shapes defined by ink strokes and you won’t need it when creating windows with well-known shapes: public MainWindow() In the code-behind we need to unpack the geometry information about the ink stroke and clip the window accordingly. Rect inkBounds = Ī = viewBounds.X + inkBounds.Left Ī = viewBounds.Y + inkBounds.Top Ī = winBounds.Width Ī = winBounds.Height Rect viewBounds = ApplicationView.GetForCurrentView().VisibleBounds private async void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args) You obviously won’t need all this code if you are creating windows of well-known shapes. Most of the code here is specific to getting the geometry info from the collected ink stroke and passing it down to the WPF. To pass on the geometry details about the shape of the window we are using the local AppData settings. The gist on the UWP side is that we are using the FullTrustProcessLauncher API to create the WPF window. Here we need to add the declaration for our desktop extension, so that the UWP app can activate the WPF process for creating the windows. The appxmanifest file in the Package project is the one that is relevant at deployment time. A Windows App Packaging project to package the two together for distribution (“Package”).A WPF project that provides the windowing feature (“WPF”).The actual UWP main app (“Sketch-a-Window”).The Visual Studio solution for this sample consists of three projects: Source Code Walkthrough Project Structure Just show me the code on GitHub and let me install the sample app from the Store … Read on for details on how to implement this scenario with just a couple of lines of code. The sample app works on build 1709 and above (though the features used here are already available since build 1607). In my sample app here I am just hosting a re-styled WPF button that serves as my close button. Note though that the XAML Island itself needs to be rectangular, if you decide to use one. In the secondary WPF windows you would typically host WPF controls to implement your UI – and now with XAML Islands (introduced in 1809) you could also host UWP controls. How arbitrary the shape can be you ask? Well, if you can draw it, it can be your window’s shape! To prove my claim my sample actually lets you hand-draw windows using the UWP InkCanvas control – check it out in the video: I figured it would be useful to put together a quick sample and write-up for this, as I don’t believe we’ve ever had any docs/blogs/sample to date that describe how to create an arbitrarily shaped chromeless window from a UWP app. My app/main window itself needs be UWP because of some other requirements. ![]() UWP’s ApplicationView/Window doesn’t support chromeless, non-rectangular windows – but with the Windows application model being an à la carte platform, this can be accomplished by adding a desktop extension to my UWP app package that uses a WPF Window to provide the required rich windowing capabilities. One of my requirements involves a creating a secondary chromeless, non-rectangular utility window (that is also semi-transparent and topmost). On my way back home from the IoT in Action event in Taipei I had a several hours time to work on a small personal spare-time app project that I am hoping to publish to the Store soon. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |