BabySmash! For Babies and Toddlers
CodePlex Home
Register
|
Sign In
|
CodePlex Home
Home
Downloads
Discussions
Issue Tracker
Source Code
People
License
Close
RSS
All Project Updates
Discussions
Issue Tracker
Releases
Reviews
Source Code
Wiki & Documentation
RSS
Basic View
|
Advanced View
|
Create New Item
Item
1
of
1
Previous
|
Next
1
vote
closed
Move the shapes in ShapeFactory into Xaml
Description
Instead of defining the shapes in code, i'd define them as application resources in App.xaml.
File Attachments
No files are attached
Closed
Jun 12 2008 at 11:50 PM
by
shanselman
Cool!
Comments
most recent at top
(
show oldest at top
)
shockstump
wrote
Jun 12 2008 at 10:27 PM
You can use Blend 2.5 June Preview to create Style resources in the WYSIWYG IDE, so you don't need to code these by hand :-)
shanselman
wrote
Jun 12 2008 at 8:03 PM
Cool. I'll try this. How does this make things better in Blend? The Style markup looks like something I'll need to make by hand?
shockstump
wrote
Jun 12 2008 at 8:59 AM
good point! ok, so rather than storing the actual shapes in the resource dictionary, store their styles:
<Application.Resources>
<Style x:Key="square" TargetType="Rectangle">
<Setter Property="Width" Value="380"/>
<Setter Property="Height" Value="380"/>
<Setter Property="StrokeThickness" Value="5"/>
<Setter Property="Stroke" Value="Black"/>
</Style>
</Application.Resources>
Then ShapeFactory can apply the styles:
Shape shape = new Rectangle();
shape.Style = Application.Current.Resources["square"] as Style;
This approach still has the advantage of letting your designer make your shapes look nice for you using Blend.
shanselman
wrote
Jun 12 2008 at 6:39 AM
So, I tried that just now and have a problem. When I add the shape that is in a resource, TWICE, the first one displayed disappears, because, of course, it's the SAME shape. How do I get a shape out of a resource and REUSE it?
shanselman
wrote
Jun 12 2008 at 6:33 AM
Good idea! I tried this but thought I got an error when I added more than one. I'll try again.
shockstump
wrote
Jun 11 2008 at 11:30 PM
like this:
<Application.Resources>
<Rectangle x:Key="square"
Height="380"
Width="380"
StrokeThickness="5"
Stroke="Black"
/>
<Ellipse x:Key="circle"
Height="400"
Width="400"
StrokeThickness="5"
Stroke="Black"
/>
</Application.Resources>
You can then load the shapes in your ShapeFactory:
Shape s= Application.Current.Resources["square"] as Shape ;
The benefit of this is that your 'designer' is able to make your shapes look pretty in Blend whilst you concentrate on the code
Sign in to add a comment
Comment:
Work Item Details
Item #
1369
Status
Closed
Type
Issue
Impact
Low
Release
Unassigned
Assigned To
Unassigned
Component
No Component Selected
Reported On
Jun 11 2008 at 11:28 PM
Reported By
shockstump
Updated On
Jun 12 2008 at 11:50 PM
Updated By
shanselman
Closed On
Jun 12 2008 at 11:50 PM
Closed By
shanselman
Wiki Link
[workitem:1369]
Updating...
© 2006-2009 Microsoft
|
About CodePlex
|
Privacy Statement
|
Terms of Use
|
Code of Conduct
|
Advertise With Us
|
Version 2009.10.27.15987