udayKolluru
Topic Author
Posts: 2
Joined: 02 Oct 2015, 08:49

Control Colors

20 Oct 2015, 11:44

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:
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Control Colors

20 Oct 2015, 13:06

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.
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Control Colors

20 Oct 2015, 18:24

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.

Who is online

Users browsing this forum: No registered users and 0 guests