Page 1 of 1

Control Colors

Posted: 20 Oct 2015, 11:44
by udayKolluru
Hi,

I am using trial version Of Noesis GUI 1.24 package . In unity 5.2.1

Here I am trying to change the Noesis Controls (color), Suppose if there is check Box, in it Check Mark is Blue I want To Change it red how can i Change it , I want to change all control colors as per requirement.

Can anybody help me to sort out this problem. :roll: :roll: :roll:

Re: Control Colors

Posted: 20 Oct 2015, 13:06
by sfernandez
Control appearance is specified by its Template property, where a ControlTemplate defines the tree of visual elements that are shown for a type of control.

For example, a simple CheckBox template could be:
<CheckBox Content="Some check" HorizontalAlignment="Center" VerticalAlignment="Center">
    <CheckBox.Template>
        <ControlTemplate TargetType="CheckBox">
            <Border Background="Transparent">
                <BulletDecorator>
                    <BulletDecorator.Bullet>
                        <Border x:Name="bd" BorderBrush="Black" BorderThickness="1"
                            Padding="1" Width="16" Height="16" VerticalAlignment="Center">
                            <Path x:Name="chk" Data="M0,0 L10,10 M0,10 L10,0"
                                Stroke="Red" StrokeThickness="2" Stretch="Fill"/>
                        </Border>
                    </BulletDecorator.Bullet>
                    <ContentPresenter VerticalAlignment="Center" Margin="8,0,0,0"/>
                </BulletDecorator>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="bd" Property="Background" Value="WhiteSmoke"/>
                </Trigger>
                <Trigger Property="IsChecked" Value="False">
                    <Setter TargetName="chk" Property="Visibility" Value="Hidden"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </CheckBox.Template>
</CheckBox> 
As you can see the color of each visual part is defined by the template elements. But you can bind some properties to the templated control, so changes in Control properties will modify the appearance of the template:
<CheckBox Content="Some check" HorizontalAlignment="Center" VerticalAlignment="Center"
    BorderBrush="Green">
    <CheckBox.Template>
        ...
                            <Path x:Name="chk" Data="M0,0 L10,10 M0,10 L10,0"
                                Stroke="{TemplateBinding BorderBrush}" StrokeThickness="2" Stretch="Fill"/>
        ...
    </CheckBox.Template>
</CheckBox> 
The last CheckBox will have the a green check mark instead.

Re: Control Colors

Posted: 20 Oct 2015, 18:24
by jsantos
By the way, all your templates can be shared in a separate XAML. There are several themes in the Unity package at Assets\NoesisGUI\Themes.

More information in the Styles and Templates Tutorial.