techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Nov 24, 2012, 11:09 AM   #1
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

How can we change the header font color of WPF group box

Well check my attachments, I could not change!
But here I found this.
Hope it helps

Kreij you are right; the new programming avenue (WPF instead of classical form) is a big headache!!
Attached Thumbnails
Click image for larger version

Name:	photo1.jpg
Views:	68
Size:	111.0 KB
ID:	49161   Click image for larger version

Name:	photo2.jpg
Views:	72
Size:	75.8 KB
ID:	49162  
Attached Files
File Type: zip WpfApplication1.zip (11.9 KB, 20 views)
MrSeanKon is offline  
Reply With Quote
Old Nov 24, 2012, 12:05 PM   #2
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,113 (5.28/day)
Thanks: 591
Thanked 5,491 Times in 2,935 Posts

System Specs

What was stated in the link you posted worked for me.
Code:
<GroupBox Height="100" Width="200">
  <GroupBox.Header>
    <Label Foreground="Red">My Red GroupBox Header</Label>
  </GroupBox.Header>
</GroupBox>
Once you define the Header's Label in the above manner in code you then be able to click on it in the visual editor as see all of the Label's properties and will be able to use the property bar.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old Nov 28, 2012, 12:02 AM   #3
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

But if we add two buttons for example something is going mystery and I am getting
Check the simple WPF programs in attachment.
Damn many headaches cos WPF during the first days....
Attached Files
File Type: zip Code.zip (24.9 KB, 24 views)
MrSeanKon is offline  
Reply With Quote
Old Nov 28, 2012, 11:07 AM   #4
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,113 (5.28/day)
Thanks: 591
Thanked 5,491 Times in 2,935 Posts

System Specs

I didn't run the code and you didn't really explain what was not exactly working, but it looks like you need to put the buttons inside the groupbox
Code:
<GroupBox ...>
   <GroupBox.Header ...>
      <Whatever ....>
   </GroupBox.Header>
   <Button ...></Button>
   <Button ...></Button>
</GroupBox>
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
Old Nov 28, 2012, 11:33 AM   #5
FordGT90Concept
"I go fast!1!11!1!"
 
FordGT90Concept's Avatar
 
Join Date: Oct 2008
Location: IA, USA
Posts: 10,574 (6.29/day)
Thanks: 1,752
Thanked 2,596 Times in 1,960 Posts

System Specs

Highly recommend putting some kind of container (e.g. a Grid) in the GroupBox instead of having the buttons land where they may.
__________________
Golden Rule of Programming: Never assume.

try { SteamDownload(); }
catch (Steamception ex) { RageQuit(); }
FordGT90Concept is offline  
Crunching for Team TPU
Reply With Quote
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
Old Nov 28, 2012, 04:27 PM   #7
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,113 (5.28/day)
Thanks: 591
Thanked 5,491 Times in 2,935 Posts

System Specs

Sorry, Sean. I didn't have time to dig into it father this morning as I had to leave for work. I will poke around with it when I get home tonight.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
Old Nov 28, 2012, 05:04 PM   #8
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

OK don't worry; take your time!
But I have to continue a bit....
Well as I try to be familiar with this new field (WPF) the problem is inside XAML commands.
Pressing a button groupbox's header color is reset to the default value (blue).
Thus we have to add something equivalent in C#.
For example look the photo. It is a conversion from XAML to C#.
I am seeking to MSDN forums to find a small part of code but I have not found yet.
Attached Thumbnails
Click image for larger version

Name:	jh.jpg
Views:	23
Size:	69.4 KB
ID:	49235  
MrSeanKon is offline  
Reply With Quote
Old Nov 29, 2012, 05:28 PM   #9
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,113 (5.28/day)
Thanks: 591
Thanked 5,491 Times in 2,935 Posts

System Specs

Sorry for the delay, I'm really busy lately.

The reason you are having problems is that you are modifying the header in the button events instead of the TextBlock, so basically you are saying "replace the TextBlock with this header content." Since you are not specifying any font or color characteristics it is using the system default.

Give the TextBlock a name, and then in your button events change the text by using textBlockName.Text="Language" (or the Greek equivalent). This will change the text in the TextBlock but not any of its other properties.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old Nov 29, 2012, 08:12 PM   #10
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

The photo shows what Kreij means.
Thanks buddy!
I could not think this solution!
I got many times in mess and was very angry with WPF programming. But I must overtake the problems!

As we live we will learn Socrates
Attached Thumbnails
Click image for larger version

Name:	jh1.png
Views:	26
Size:	24.2 KB
ID:	49242  
MrSeanKon is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change Windows 7 highlight color Aleksander General Software 2 Nov 13, 2012 11:20 AM
HD6950 fan header change renq AMD / ATI 7 Mar 28, 2011 06:49 PM
How can I change the speed or order of a program at startup? sttubs General Software 7 Jul 19, 2010 03:29 PM
Vista font gone wrong and wont change back Shadow_ID General Hardware 14 Jul 13, 2008 10:54 PM


All times are GMT. The time now is 03:13 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts