- JinxxNoesis
- Posts: 7
- Joined:
Controls are transparent and pink
All my elements are transparent and pink. I cant set the background colour on anything.
I've attached some screenshots here:
Unity:
https://i.imgur.com/xe14KDo.png
Code:
https://i.imgur.com/ucFDUXb.png
https://i.imgur.com/BBFRYnL.png
I've attached some screenshots here:
Unity:
https://i.imgur.com/xe14KDo.png
Code:
https://i.imgur.com/ucFDUXb.png
https://i.imgur.com/BBFRYnL.png
- JinxxNoesis
- Posts: 7
- Joined:
Re: Controls are transparent and pink
Thanks for the incredibly fast reply.
- JinxxNoesis
- Posts: 7
- Joined:
Re: Controls are transparent and pink
Can i set the BasedOn property in a global theme?
Edit: I copied and pasted the example into my code and am still faced with a pink button. Am I missing something obvious?
https://i.imgur.com/NpXR8KY.png
https://i.imgur.com/vCHeeZk.png
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="PrimaryBackground">#44A7F7</Color>
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="{StaticResource PrimaryBackground}"></SolidColorBrush>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="{StaticResource ResourceKey=PrimaryBackgroundBrush}"/>
</Style>
</ResourceDictionary>
https://i.imgur.com/NpXR8KY.png
https://i.imgur.com/vCHeeZk.png
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Controls are transparent and pink
The StaticResource you set in BasedOn will resolve to any previous style definition of that same type. If there is none, then it will fallback to our internal theme with pink templates.Can i set the BasedOn property in a global theme?
The idea is that you define your own theme with Styles and Templates and set it in the ApplicationResources, so you don't end using our debug pink templates. You can start by setting the NoesisTheme we provide and then tweak the style for the controls you use in your application.
If you define a local style in you xaml and using the BasedOn still shows the pink template is because you haven't set any ApplicationResources with a style and template for that control.I copied and pasted the example into my code and am still faced with a pink button. Am I missing something obvious?
- JinxxNoesis
- Posts: 7
- Joined:
Re: Controls are transparent and pink
Thing is I set this as my application theme and it still shows pink
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Controls are transparent and pink
If you have set the following dictionary as the ApplicationResources:
It is expected that you see the pink templates, because you are defining a Style for all Button controls that has no Template property specified, so it falls back to our internal debug template.
I recommend you include our NoesisTheme as base, and the tweak the control styles and templates you need. The easiest way could be by just merging it in your ApplicationResoruces dictionary:
Please let me know if that works.
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="PrimaryBackground">#44A7F7</Color>
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="{StaticResource PrimaryBackground}"></SolidColorBrush>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="{StaticResource ResourceKey=PrimaryBackgroundBrush}"/>
</Style>
</ResourceDictionary>
I recommend you include our NoesisTheme as base, and the tweak the control styles and templates you need. The easiest way could be by just merging it in your ApplicationResoruces dictionary:
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assets/NoesisGUI/Theme/NoesisTheme.DarkBlue.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Color x:Key="PrimaryBackground">#44A7F7</Color>
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="{StaticResource PrimaryBackground}"></SolidColorBrush>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Background" Value="{StaticResource ResourceKey=PrimaryBackgroundBrush}"/>
</Style>
</ResourceDictionary>
- JinxxNoesis
- Posts: 7
- Joined:
Re: Controls are transparent and pink
So after two days of toying around, it seems that the application resource set in the noesis settings asset isn't being applied to any user controls. I looked in the samples, those all seem to have the resources within the xaml. Not quite sure what to do at this point other than directly adding the resources inside the controls respectively
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: Controls are transparent and pink
A control in Noesis gets its appearance from the Template property. The template defines the visual tree (UI elements) that compose the appearance of the control. It can also contain triggers and visual states to change the appearance depending on the control state. A theme dictionary must define the styles and templates for the controls used in your application (if you don't define the template it will show our minimalistic pink template). In your example it could be like this:
This Button style is using Button type as implicit key, so all buttons in your xamls will use the style and template defined in the theme:
You have to set the theme dictionary in ApplicationResources property under Noesis Settings.
Code: Select all
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="PrimaryBackground">#44A7F7</Color>
<Color x:Key="PrimaryOverBackground">#64C7F7</Color>
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="{StaticResource PrimaryBackground}"/>
<SolidColorBrush x:Key="PrimaryBackgroundOverBrush" Color="{StaticResource PrimaryOverBackground}"/>
<ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type Button}">
<Border x:Name="Bd" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource PrimaryBackgroundOverBrush}" TargetName="Bd"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource ResourceKey=PrimaryBackgroundBrush}"/>
<Setter Property="Template" Value="{StaticResource TemplateTemplate}"/>
</Style>
</ResourceDictionary>
Code: Select all
<StackPanel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Content="Button 1"/>
<Button Content="Button 2"/>
<Button Content="Button 3"/>
</StackPanel>
- JinxxNoesis
- Posts: 7
- Joined:
Re: Controls are transparent and pink
Finally fixed, thanks you so much.
Who is online
Users browsing this forum: No registered users and 3 guests