View Single Post
Old Nov 28, 2012, 11:40 AM   #6
MrSeanKon
200 Posts
 
MrSeanKon's Avatar
 
Join Date: Nov 2006
Location: Athens in love with Anna :)
Posts: 253 (0.11/day)
Thanks: 28
Thanked 65 Times in 24 Posts

It is better to open the code in Visual Studio (when you have free time) and you will understand easily what is going mystic
But let me to explain you right now.
I define a groupbox which has a header and two buttons inside (button_EN & button_GR). Pressing a button translates the controls of WPF form from English to Greek and vice versa (buttonEN_Click & buttonGR_Click events).
If the main XMAL file is this:

Code:
<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Header's color and font change" Height="150" Width="300" ResizeMode="NoResize">
    <Grid>
        <GroupBox Name="grouplang" BorderThickness="3" Margin="20,10,30,20">
            <GroupBox.Header>
                <TextBlock FontSize="14" Foreground="Green" FontWeight="Bold" FontFamily="Times New Roman">Language</TextBlock>
            </GroupBox.Header>
        </GroupBox>
        <Button Content="Ελληνικά" Height="23" HorizontalAlignment="Left" Margin="50,50,0,0" Name="buttonGR" VerticalAlignment="Top" Width="75" Click="buttonGR_Click" />
        <Button Content="English" Height="23" HorizontalAlignment="Left" Margin="150,50,0,0" Name="buttonEN" VerticalAlignment="Top" Width="75" Click="buttonEN_Click" />
    </Grid>
</Window>
after pressing a button damn header's color & font's size/family changes....
Adding some definitions for TextBlock only the color changes (font family & size not).

Code:
<Window x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Here only the color changes" Height="150" Width="300" ResizeMode="NoResize">
    <Grid>
        <GroupBox Name="grouplang" BorderThickness="3" FontSize="14" Foreground="Green" FontWeight="Bold" FontFamily="Times New Roman" Margin="20,10,30,20">
            <GroupBox.Header>
                <TextBlock FontSize="14" Foreground="Green" FontWeight="Bold" FontFamily="Times New Roman">Language</TextBlock>
            </GroupBox.Header>
        </GroupBox>
        <Button Content="Ελληνικά" Height="23" HorizontalAlignment="Left" Margin="50,50,0,0" Name="buttonGR" VerticalAlignment="Top" Width="75" Click="buttonGR_Click" />
        <Button Content="English" Height="23" HorizontalAlignment="Left" Margin="150,50,0,0" Name="buttonEN" VerticalAlignment="Top" Width="75" Click="buttonEN_Click" />
    </Grid>
</Window>
Thus my question is how can I access groupbox's header color during execution adding the necessary commands in C#?
For WF case it is simple because WF design is based on C#.
MrSeanKon is offline  
Reply With Quote