Hi,
The template from WPF doesnt seem to work as it does in WPF, if you notice the right hand top BorderThickness is bit wider than the rest. not sure why it is doing that. playing around with the column widths in the Grid in the Template would help
Thanks for the control, great work. I was having a problem in Firefox getting it to render the border and header (didn’t try IE). The border and header weren’t showing only the content. I added the following ctor to match your other controls and it worked just fine.
public GroupBox()
{
DefaultStyleKey = typeof(GroupBox);
}
I am not sure what you meant. did you make the necessary changes to work in the released version of silverlight, like creating a folder called themes and moving the generic.xaml file into that folder?
Hi AK,
Name the 2 border elements in generic.xaml border and border1 for ex
Add code to groupbox.cs similar to the following
In the constructor
add an eventhandler
IsEnabledChanged += new DependencyPropertyChangedEventHandler(GroupBox_IsEnabledChanged);
declare 2 variables in the class as following
Border b;
Border b1;
//event handler
void GroupBox_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
b.BorderBrush = new SolidColorBrush(Colors.Magenta);
b1.BorderBrush = new SolidColorBrush(Colors.Magenta);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
b = GetTemplateChild(”border”) as Border;
b1 = GetTemplateChild(”border1″) as Border;
}
[...] In case anyone is interested, I did find one other groupbox control out there but it was created before the RTW and requires a little work to get it running on RTW and the spacing around the header was a bit off. Nevertheless, kudos to Lee for thinking of it first and getting the ball rolling. (http://leeontech.wordpress.com/2008/04/10/groupbox/) [...]
Hi, lee
I find that if i set the groupbox’s isEnabled property to false,
the Header’s color is still black.
Do you have any solutions to change the color to gray when the isEnabled is set to false?
Hi I’ve tried you control but it gives me an error “Object reference not set to an instance of an object.” at this line: HeaderContainer.SizeChanged += HeaderContainer_SizeChanged;
I’m using it in the latest version of silverlight 2.0
It doesn’t work i have the same error, but if i comment that line “HeaderContainer.SizeChanged += HeaderContainer_SizeChanged;” it show’s the content in the groupbox but not the header.
Mybe I have this error because all the files are in the same projject the generic.xaml and the coude behind file it’s no timported from a diffrent project like in your test sample.
Hello,
I think the spacing before text “Options” in groupbox looks a lit bit far…
Michael Sync
April 14, 2008
Hi,
The template from WPF doesnt seem to work as it does in WPF, if you notice the right hand top BorderThickness is bit wider than the rest. not sure why it is doing that. playing around with the column widths in the Grid in the Template would help
lee
April 14, 2008
Hi,
Thanks for the control, great work. I was having a problem in Firefox getting it to render the border and header (didn’t try IE). The border and header weren’t showing only the content. I added the following ctor to match your other controls and it worked just fine.
public GroupBox()
{
DefaultStyleKey = typeof(GroupBox);
}
Earnie
June 25, 2008
yes, we need to do that as that is breaking change in beta2
lee
June 25, 2008
I had to comment out BorderBrush and BorderBrushProperty to get this to work with latest Silverlight 2.0.
DRB
September 25, 2008
Thanks for the comment. I did not get a chance to update this to beta2. This is very helpful
lee
September 25, 2008
Hi,
This is very good & useful article.
But this GroupBox is not working under DataTemplate.
Is there any way to add an eventhandler to this GroupBox
grp_Target(object sender, DataTransferEventArgs e) will e defined in my C# file.
Thanks
tanusree
November 5, 2008
This groupBox is not working under DataTemplate.
——
tanusree
November 5, 2008
I am not sure what you meant. did you make the necessary changes to work in the released version of silverlight, like creating a folder called themes and moving the generic.xaml file into that folder?
lee
November 5, 2008
When i use it in Silverlight RC0, I can only see the radiobutton, but groupbox.
Ak
November 11, 2008
Hi AK,
Name the 2 border elements in generic.xaml border and border1 for ex
Add code to groupbox.cs similar to the following
In the constructor
add an eventhandler
IsEnabledChanged += new DependencyPropertyChangedEventHandler(GroupBox_IsEnabledChanged);
declare 2 variables in the class as following
Border b;
Border b1;
//event handler
void GroupBox_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
b.BorderBrush = new SolidColorBrush(Colors.Magenta);
b1.BorderBrush = new SolidColorBrush(Colors.Magenta);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
b = GetTemplateChild(”border”) as Border;
b1 = GetTemplateChild(”border1″) as Border;
}
lee
February 9, 2009
looks like template is not being applied. did you create a Themes folder and move generic.xaml into that?
lee
November 11, 2008
for it to work in RTM
1. create a folder called themes and move generic.xaml into that
2. replace ContentPresenter with ContentControl in generic.xaml
3. Add the following constructor to groupbox.cs
public GroupBox()
{
DefaultStyleKey = typeof(GroupBox);
}
lee
November 11, 2008
[...] In case anyone is interested, I did find one other groupbox control out there but it was created before the RTW and requires a little work to get it running on RTW and the spacing around the header was a bit off. Nevertheless, kudos to Lee for thinking of it first and getting the ball rolling. (http://leeontech.wordpress.com/2008/04/10/groupbox/) [...]
Silverlight GroupBox control « Programmer Payback
November 26, 2008
Hi, lee
I find that if i set the groupbox’s isEnabled property to false,
the Header’s color is still black.
Do you have any solutions to change the color to gray when the isEnabled is set to false?
Thanks
Ak
February 9, 2009
Hi I’ve tried you control but it gives me an error “Object reference not set to an instance of an object.” at this line: HeaderContainer.SizeChanged += HeaderContainer_SizeChanged;
I’m using it in the latest version of silverlight 2.0
XAML Templates
February 13, 2009
I am thinking, Template is not being applied.
did you do this
for it to work in RTM
1. create a folder called themes and move generic.xaml into that
2. replace ContentPresenter with ContentControl in generic.xaml
3. Add the following constructor to groupbox.cs
public GroupBox()
{
DefaultStyleKey = typeof(GroupBox);
}
lee
February 13, 2009
It doesn’t work i have the same error, but if i comment that line “HeaderContainer.SizeChanged += HeaderContainer_SizeChanged;” it show’s the content in the groupbox but not the header.
Mybe I have this error because all the files are in the same projject the generic.xaml and the coude behind file it’s no timported from a diffrent project like in your test sample.
XAML Templates
February 16, 2009