|
-
Aug 6th, 2009, 03:16 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] style window
First of all does anybody have any good tutorials for changing the default look of the window in a wpf project. I am using Microsoft Expression Blend(amazing tool).
Now to my question. I am trying to style my wpf window. I have been able to change its default background and round the corners while enabling transparency. It looks amazing (probably just to me though lol) and was easy to do. However the next part seems a little more confusing to me. I am going to go through my steps.
First I clicked on the window from the objects and timeline pane. Then I went to edit template->edit a copy->named it style1. After that I changed the border that was already there to a different cornerradius and giving it a name of border1. I then added a rectangle (named rectangle1) to the upper right hand corner with its stroke set to 0. Then I went back and edited another copy to just make the corners have no cornerradius and named it style2.
Now for what I am trying to do. I would like to make it so that when the form is maximized I can take the corner radius off. The problem is I do not know how to apply a resource through code and cant find any info on it. Basically if I wanted to do this in Microsoft Expression Blend I could go to the window and right click it. Then go down to edit template->apply resource->select my template. Any ideas on how to do this through code?
If I helped you please rate me.
-
Aug 6th, 2009, 04:31 PM
#2
Re: style window
Try something like this:
vb.net Code:
Dim Style2 As Style = DirectCast(FindResource("Style2"), Windows.Style)
Me.Style = Style2
Assuming your style has a key of "Style2" in your XAML resources and you want to apply it to the current window of course
-
Aug 6th, 2009, 06:12 PM
#3
Thread Starter
Hyperactive Member
Re: style window
Thank you so much it worked perfectly. You would think that there was an easier way to do that through code such as this but I guess not:
Code:
this.Style.ApplyResource("Style2");
For anyone interested here is the C# version:
Code:
Style Style2 = (Style)FindResource("Style2");
this.Style = Style2;
Does anyone know where I can find any resources on editing windows in wpf? Also I would like to know how to use a custom control in wpf through code. I have found tutorials on how to create custom controls and how to create them in xaml but none that actually show how to use the control in code. Any help is appreciated as always.
If I helped you please rate me.
-
Aug 6th, 2009, 06:15 PM
#4
Re: style window
You should probably create a new thread for that and mark this one as resolved seen as the original question has been answered 
(thats my way of saying I dont know )
-
Aug 6th, 2009, 08:19 PM
#5
Thread Starter
Hyperactive Member
If I helped you please rate me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|