View Issue Details

IDProjectCategoryView StatusLast Update
0001664NoesisGUIC# SDKpublic2020-05-01 21:49
Reporterstonstad Assigned Tosfernandez  
PrioritynormalSeverityblock 
Status assignedResolutionopen 
Product Version3.0 
Summary0001664: Theming and Resource Dictionary Behavior
Description

What are the breaking changes? I am running into a large number of issues related to theming and UI. Many static resources and naming has changed. The behavior of controls and containers also appear changed. What should a developer be looking for when upgrading from 2.x to 3.x?

Enclosed Screenshot

1) Unexpected purple backgrounds
2) Container layouts seem to have changed to alignment center -- or they are not being respected.
3) Many custom user controls are broken.

Attached Files
Odd Behavior.PNG (3,084,670 bytes)
PlatformAny

Activities

stonstad

stonstad

2020-04-23 20:10

reporter   ~0006246

For reference, here is how this screen appears before upgrading to v3. https://stellarconquest.com/images/screenshots/08.png

stonstad

stonstad

2020-04-23 21:11

reporter   ~0006256

The purple areas are ScrollViewers. Not sure why they are purple, however.

stonstad

stonstad

2020-04-23 21:22

reporter   ~0006259

Last edited: 2020-04-23 21:26

OK, this was caused by not including any reference to NoesisTheme.Styles.xaml in my XAML resource hierarchy. Previously, I used the built-in Noesis style. Not sure if things should be purple and broken without a style, but at least it makes sense and works now. This ticket is a candidate for closure. Thank you.

--

Update -- issues remain with purple backgrounds on comboboxes and togglebutton. Both controls are broken. I'm still investigating, though.

sfernandez

sfernandez

2020-04-23 21:37

manager   ~0006261

Last edited: 2020-04-23 21:38

When you see a purple background it means that Template property is falling back to our internal default style.
This is usually a result of defining a local Style that is not based in the style you have defined for your application.

<Style x:Key="CBStyle" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
...
</Style>

You can read more about this in our Themes documentation: https://www.noesisengine.com/docs/3.0/Gui.Core.StylingTutorial.html#default-styles

Please read 3.0 changelog for breaking changes: https://www.noesisengine.com/docs/3.0/Gui.Core.Changelog.html#version-3-0-0b1

stonstad

stonstad

2020-04-24 16:05

reporter   ~0006262

Thanks, Sergio. I had styles from 2.x that did not have a key defined. When I defined keys, this fixed up many of the remaining issues.

stonstad

stonstad

2020-04-24 16:08

reporter   ~0006263

My apologies -- didn't realize that. I made sure I did it right this time. Thank you.

sfernandez

sfernandez

2020-04-24 16:13

manager   ~0006264

Last edited: 2020-04-24 16:13

Don't need to apology, there are many new things in this version and is easy to get lost with the changes :)

jsantos

jsantos

2020-04-24 17:55

manager   ~0006267

Sorry about this change stonstad but it was necessary. :)

Many users of Noesis don't create a new theme, they use our default theme. Our default theme in 2.2 is a fallback theme, it is ugly in many aspects and it is using a very small font that is also ugly. Even although everything is ugly, our users use it and they show screenshots of NoesisGUI in internet that are ugly. So, we need to provide a better theme by default. But a better theme implies a bigger one, better fonts, more complex XAMLs, etc. This increases binary size of Noesis and also time for initialization, so we are penalizing the users that care about this.

So, we decided to move our theme from Core to App Framework. In the App framework we don't have restrictions so we created a nice theme with dark/light and accent variations. From the point of view of new users, it is almost the same as before, because all samples work and provide a default theme.

The theme is now available to inspect, it is no hidden in a DLL, so no obscure behaviors or things happening behind the scenes.

Our binary size and performance improved.

stonstad

stonstad

2020-04-24 18:27

reporter   ~0006269

Last edited: 2020-04-24 18:28

I appreciate the background and I appreciate the added performance. I am going through and finding places where I incorrectly defined XAML, such as not specifying a key or not used based on. In most cases I have it working now -- but there are a few styles that I'm struggling with.

Here is an example of one -- a TextBox. It is pink if I reference the style, below.

<TextBox x:Name="_InputTextBox" Grid.Row="1" Style="{StaticResource Heading3PrimaryTextBox}" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="2, 15, 2, 2"/>

...

<Style x:Key="Heading3PrimaryTextBox" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
</Style>

I was missing BasedOn. I added it but it remains pink. Removing "Style="{StaticResource Heading3PrimaryTextBox}"" allows it to work.

sfernandez

sfernandez

2020-04-24 19:53

manager   ~0006270

Are you defining the styles in your application resources with a key or just the TargetType?

In case you have them with a key, you need to use that in the BasedOn StaticResource.

Application.Resources.xaml:

<ResourceDictionary ...>
<Style x:Key="SC.TextBoxStyle" TargetType="TextBox">
...
</Style>
...
</ResourceDictionary>

MainWindow.xaml:

<UserControl ...>
<UserControl.Resources>
<Style x:Key="CustomTextBox" TargetType="TextBox" BasedOn="{StaticResource SC.TextBoxStyle}">
...
</Style>
</UserControl.Resources>
...
</UserControl>

stonstad

stonstad

2020-04-24 20:51

reporter   ~0006271

My XAML hierarchy is as follows:

Resources.xaml:

<ResourceDictionary Source="/Assets/NoesisGUI/Theme/NoesisTheme.Brushes.DarkBlue.xaml" />
<ResourceDictionary Source="/Assets/NoesisGUI/Theme/NoesisTheme.Fonts.xaml" />
<ResourceDictionary Source="/Assets/NoesisGUI/Theme/NoesisTheme.Styles.xaml" />
<ResourceDictionary Source="ResourcesImages.xaml"/>
<ResourceDictionary Source="ResourcesCommon.xaml"/>
<ResourceDictionary Source="ResourcesTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

I am defining the style in ResourcesCommon.xaml:
<Style x:Key="Heading3PrimaryTextBox" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
</Style>

And then using it in a UserControl like this:

<UserControl>
...
<TextBox Style="{StaticResource Heading3PrimaryTextBox}"/>
</UserControl>

I understand I have nesting -- but is there something wrong with this hierarchy? I am thinking it is pretty standard for WPF/UWP...

stonstad

stonstad

2020-04-28 17:11

reporter   ~0006293

Just to clarify, in the example above (posted on 4/24) the TextBox in question is uninitialized pink. It shouldn't be based on the XAML shared, right? I think my next step is to share a repo project.

sfernandez

sfernandez

2020-04-28 17:15

manager   ~0006295

If you could share a repro project it would help, maybe there is a bug and you have nothing wrong on your side.

stonstad

stonstad

2020-05-01 21:49

reporter   ~0006308

Yes, I need to get you a repro project. I wonder if what I am seeing here is related to 0001678.

Issue History

Date Modified Username Field Change
2020-04-23 20:09 stonstad New Issue
2020-04-23 20:09 stonstad File Added: Odd Behavior.PNG
2020-04-23 20:10 stonstad Note Added: 0006246
2020-04-23 21:11 stonstad Note Added: 0006256
2020-04-23 21:22 stonstad Note Added: 0006259
2020-04-23 21:25 stonstad Note Edited: 0006259
2020-04-23 21:26 stonstad Note Edited: 0006259
2020-04-23 21:37 sfernandez Assigned To => sfernandez
2020-04-23 21:37 sfernandez Status new => feedback
2020-04-23 21:37 sfernandez Note Added: 0006261
2020-04-23 21:38 sfernandez Note Edited: 0006261
2020-04-24 16:05 stonstad Note Added: 0006262
2020-04-24 16:05 stonstad Status feedback => assigned
2020-04-24 16:08 stonstad Note Added: 0006263
2020-04-24 16:13 sfernandez Note Added: 0006264
2020-04-24 16:13 sfernandez Note Edited: 0006264
2020-04-24 17:55 jsantos Note Added: 0006267
2020-04-24 18:27 stonstad Note Added: 0006269
2020-04-24 18:28 stonstad Note Edited: 0006269
2020-04-24 19:53 sfernandez Status assigned => feedback
2020-04-24 19:53 sfernandez Note Added: 0006270
2020-04-24 20:51 stonstad Note Added: 0006271
2020-04-24 20:51 stonstad Status feedback => assigned
2020-04-28 17:11 stonstad Note Added: 0006293
2020-04-28 17:15 sfernandez Note Added: 0006295
2020-05-01 21:49 stonstad Note Added: 0006308
2020-05-01 21:49 stonstad Summary Noesis 3.0 Beta Breaking Changes => Theming and Resource Dictionary Behavior
2020-05-01 21:49 stonstad Description Updated