Windows UWP development from WPF Deverloper’s perspective

It took me a while to get myself to interest in development on Universal Windows Platform. Without going to Build conferences or watching them it is hard to pick up related information without knowing what you are looking for. Once one starts reading it is overwhelming: What is WinRT? Difference between Windows Store Apps and Universal Windows Apps? What is difference between UWP and UWA? Windows 10 is announced as cross-platform and then you read that Android and IOS are supported through xamarin, but only significantly less code if developer uses Xamarin Forms. Xamarin is not free and Xamarin forms does not seem like something that would let me build whatever I want. Then you see that it is cross-platform in a sense accross Windows phone/PC/HoloLens/XBox devices… Edit: Looks like Microsoft purchased Xamarin, so will will see bout its future.

Since I worked with WPF for several years, I was glad that UWP also used XAML to describe the UI. Many things were different though.

There is no DockPanel, but I have found a new RelativePanel. I wanted to use LastChildFill=True, in order to make an object fill available space. After a bit of googling I have found a bit counter-intuitive way (not really, more like so unexpected that I did not think about even trying it):

<Slider RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True" ...>

Soon I have realized that RelativePanel is very powerful. Making layout of anything was much easier in XAML than in CSS, but now CSS seems like MFC in comparison.

UniformGrid has been also removed, I also could not find ButtonBase.Click Event…

The new approach to creating adaptive UI is simpler than in WPF.

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WindowStates">
<VisualState x:Name="WideState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="800" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="PlayerControlsGrid.HorizontalAlignment" Value="Right" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="PlayerControlsGrid.HorizontalAlignment" Value="Center" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

Simple, but intelisense did not help me with PlayerControlsGrid.(…)

Designer is still a bit buggy. Editing the XAML file I would often get

Error HRESULT E_FAIL has been returned from a call to a COM component.

I would need to close and reopen the designer to continue working.

Trying to use System Brush Resources in order to respect user’s theme settings I have realized that there are hundreds of brushes. In the see of gray brushes I looked for key color brushes as these should be easy to find, but naming was not exactly as I expected. I looked into Grove App as I did not want my audio player to look too different. I expected it to use system brushes, but I could not find the exact colors.

 

Link to this post
Tags: , , , , ,

Categorised in: