UWP on desktop closed by top X button – no event

A restricted capability confirmAppClose was added in Windows 10 version 1703 (build 10.0.15063) in order to provide apps the ability to intercept window closing. Manifest namespace: xmlns:rescap=”http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities” Manifest: <Capabilities> <Capability Name=”internetClient” /> <rescap:Capability Name=”confirmAppClose”/> </Capabilities> It needs extra approval when submitting to the store. But then will fire the CloseRequested event on a SystemNavigationManagerPreview instance. … Read more

AdaptiveTrigger and DataTemplate

Try wrapping your DataTemplate inside a UserControl like this – <DataTemplate> <UserControl> <Grid> <VisualStateManager.VisualStateGroups> … </Grid> </UserControl> </DataTemplate> Looks like any Control that has got a Content property will work. That’s why UserControl works, so does a ContentControl. So if you replace the UserControl with a ContentControl and give it an empty Style. It should … Read more

Encoding.GetEncoding can’t work in UWP app

We need to use the CodePagesEncodingProvider to register extended encodings included in that specific provider. See CodePagesEncodingProvider Class Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding.GetEncoding(“windows-1254”); Ref https://msdn.microsoft.com/en-us/library/system.text.encodingprovider(v=vs.110).aspx The .NET Framework Class Library provides one static property, P:System.Text.CodePagesEncodingProvider.Instance, that returns an EncodingProvider object that makes the full set of encodings available on the desktop .NET Framework Class Library available to .NET … Read more

How to use Acrylic Accent in Windows 10 Creators Update?

CREATOR UPDATE XAML You need to use a component that you put on the background of your app, let’s say a RelativePanel <RelativePanel Grid.Column=”0″ Grid.ColumnSpan=”2″ MinWidth=”40″ x:Name=”MainGrid” SizeChanged=”Page_SizeChanged”/> <RelativePanel Grid.Column=”0″ Width=”{Binding ElementName=MainGrid,Path=Width}” Background=”#28000000″/> <Grid> <!–Having content here, for example textblock and so on–> </Grid> The second RelativePanel is used to set the shadow color above … Read more

XAML GridView ItemTemplate not binding to control

My my, look at this here: <UserControl.DataContext> <local:HabitacionControlVM/> </UserControl.DataContext> Someone sold you a bill of dirty, filthy, goods. Probably one of those jerks who run around telling people DataContext = this; is a good idea. Sorry, tangent. Now look at this: <ctr:HabitacionControl Width=”70″ Height=”140″ Ubicacion=”{Binding}”/> What is that I’m seeing? Is that a pseudo-DataContext property? … Read more

How to scroll to element in UWP

A better solution is to use ChangeView instead of ScrollToVerticalOffset/ScrollToHorizontalOffset since the latter is obsolete in Windows 10. MyScrollView.ChangeView(null, abosulatePosition.Y, null, true); You can even enable scrolling animation by setting the last parameter to false. Update For the sake of completion, I’ve created an extension method for this. public static void ScrollToElement(this ScrollViewer scrollViewer, UIElement … Read more

Trigger element (XAML) is not supported in a UWP project

No, you don’t have Trigger support in UWP. A workaround is to use DataTriggerBehavior with a ChangePropertyAction to accomplish the exact same thing. xmlns:Interactivity=”using:Microsoft.Xaml.Interactivity” xmlns:Core=”using:Microsoft.Xaml.Interactions.Core” <Button x:Name=”MyButton” Width=”140″ Height=”80″ IsEnabled=”False”> <Image x:Name=”MyImage” Source=”Assets/xxx.jpg”> <Interactivity:Interaction.Behaviors> <Core:DataTriggerBehavior Binding=”{Binding IsEnabled, ElementName=MyButton}” Value=”False”> <Core:ChangePropertyAction TargetObject=”{Binding ElementName=MyImage}” PropertyName=”Opacity” Value=”0.5″ /> </Core:DataTriggerBehavior> </Interactivity:Interaction.Behaviors> </Image> </Button> Note that you will need to … Read more

Can’t see localhost from UWP app

It’s not a bug it’s a feature, called network isolation. It was introduced in Windows 8 (where Metro apps were called Windows Runtime apps). For security reasons, a UWP app that is installed in the standard manner is not allowed to make network calls to the device it is installed on. More details here and … Read more

Getting HWND off of CoreWindow object in UWP

This COM interface is only directly accessible to C++ code. In C# you have to declare it yourself and make it match the interface declaration in C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\winrt\CoreWindow.idl. Like this: using System.Runtime.InteropServices; … [ComImport, Guid(“45D64A29-A63E-4CB6-B498-5781D298CB4F”)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface ICoreWindowInterop { IntPtr WindowHandle { get; } bool MessageHandled { set; } } Obtaining the interface … Read more