Posts

Showing posts from April, 2021

ParallaxView suddenly no longer supports direct content

The current release of the XAML Controls Gallery app is compiled against Preview 4 of Project Reunion. Against that specific version the ParallaxView control works fine. The example source code for this control is: <ParallaxView Source="{Binding ElementName=listView}" VerticalShift="500">     <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" /> </ParallaxView> However, looking at this against the release version of Reunion 0.5 it suddenly throws a warning up in the XAML viewer: The type 'ParallaxView' does not support direct content. and the line  <Image Source="ms-appx:///Assets/SampleMedia/cliff.jpg" /> has a wavy line under it. I couldn't find any readily available examples that say what to do about this, but the answer is to provide this C# code. Image splash = new Image(); splash.Source = new BitmapImage(new Uri("ms-appx:///Assets/ SampleMedia/cliff .jpg")); splash.Stretch = Stretch.Unifor...

Setting a colour from a StaticResource in C#

If you want to use a {StaticResource} colour for Foreground text then there are examples aplenty on how to do this in XAML. However it did take me a while to find out how to do this if I wanted to set it in code i.e. C# So within a TextBlock construct within XAML you might say for a TextBlock called Label_CurrentClient: Foreground="{StaticResource SystemChromeMediumLowColor}" In C# you would say: Label_CurrentClient.Foreground = new SolidColorBrush((Windows.UI.Color)Application.Current.Resources["SystemChromeMediumLowColor"]);

Resource Strings - UWP vs net 5

If you store your display text in a Resources file then most of the documentation that tells you how to retrieve it will be: var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); If you try to use this code in a net 5 WinUI app then it will compile OK, but there will be a runtime error complaining about the use of GetForCurrentView, of the nature of: System.Runtime.InteropServices.COMException : 'Resource Contexts may not be created on threads that do not have a CoreWindow. (0x80073B27)' After a bit of digging around I found the equivalent call you need is var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();

My plan...

Image
A few years back I saw the Microsoft Fluent video and it captured my imagination. The follow through on this by Microsoft seems to have been rather lacklustre so far but I still regard this as a way forward for the interface design.  In early 2020 I was starting work on a new Windows project and I decided to use the new design model with the Win UI framework and a NavigationView control (as seen in the Settings programs within Windows 10). This was quite a hill to climb for me because I had been using Visual Basic.net and Windows Forms (and Web Forms) for many years, but I finally got my head into a space where I would devote my time to getting into C# and WPF. So I dived in and tried to learn it all at one. Wow, was this a challenge. The problem mainly is that this general space is so polluted with different versions of the technology but with the same control names, sop often when I tried to get something working it was because it was using sample code for a different model (e.g....