Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Customer Control Lessons Leaned So Far...

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 12-03-2006   #1 (permalink)
john
Guest


 

Customer Control Lessons Leaned So Far...

All:

I have been developiing a simple (what I thought was simple) custom
control (derived from UserControl). The basic functionality is that of
a Jeopardy-style game square --- it should be a rounded rectangle that
is filled with a gradient brush that sizes itself to the grid cell
(parent) to which it is placed.

What I have learned...

* A UserControl can only have one child element. I originally used a
Rectangle, but then could not add the question/answer text (no way to
add a Label or TextBlock, etc.). Laurent Bugnion suggested using a
container for the single allowed child and add children this way. I
tried this and used a Canvas - it worked, somewhat...

* I added 2 children to the Canvas -- a rectangle and a TextBlock.
Originally, the rectangle was marked as
Horizontal/VerticalAlignment="Stretch", with no specific Width and
Height specified. This worked when the Rectangle was the direct child
of the UserControl - but failed to display when the Rectangle was the
child of the Canvas. Apparently, the Rectangle needs to have a specific
Width and Height specified - which prevents Stretch from working...
aaaarrrggghhhh

Any insights and comments welcome. I hope the above helps others..

John - jpuopolo


My System SpecsSystem Spec
Old 12-03-2006   #2 (permalink)
Douglas Stockwell
Guest


 

Re: Customer Control Lessons Leaned So Far...

Hi John,

Canvas is only used for absolute positioning, that is, where you specify
Left, Top, Width and Height properties. Horizontal/VerticalAlignment are
unused.

I think you just need to explore the other subclasses of
System.Windows.Controls.Panel, depending on how you want to lay out the
elements, at least one of (or a combination of) Grid, StackPanel, WrapPanel,
or DockPanel should suit your needs.

- Doug




"john" <puopolo@gmail.com> wrote in message
news:1165160006.502441.322460@n67g2000cwd.googlegroups.com...
> All:
>
> I have been developiing a simple (what I thought was simple) custom
> control (derived from UserControl). The basic functionality is that of
> a Jeopardy-style game square --- it should be a rounded rectangle that
> is filled with a gradient brush that sizes itself to the grid cell
> (parent) to which it is placed.
>
> What I have learned...
>
> * A UserControl can only have one child element. I originally used a
> Rectangle, but then could not add the question/answer text (no way to
> add a Label or TextBlock, etc.). Laurent Bugnion suggested using a
> container for the single allowed child and add children this way. I
> tried this and used a Canvas - it worked, somewhat...
>
> * I added 2 children to the Canvas -- a rectangle and a TextBlock.
> Originally, the rectangle was marked as
> Horizontal/VerticalAlignment="Stretch", with no specific Width and
> Height specified. This worked when the Rectangle was the direct child
> of the UserControl - but failed to display when the Rectangle was the
> child of the Canvas. Apparently, the Rectangle needs to have a specific
> Width and Height specified - which prevents Stretch from working...
> aaaarrrggghhhh
>
> Any insights and comments welcome. I hope the above helps others..
>
> John - jpuopolo
>


My System SpecsSystem Spec
Old 12-03-2006   #3 (permalink)
Douglas Stockwell
Guest


 

Re: Customer Control Lessons Leaned So Far...

Hi John,

Canvas is only used for absolute positioning, that is, where you specify
Left, Top, Width and Height properties. Horizontal/VerticalAlignment are
unused.

I think you just need to explore the other subclasses of
System.Windows.Controls.Panel, depending on how you want to lay out the
elements, at least one of (or a combination of) Grid, StackPanel, WrapPanel,
or DockPanel should suit your needs.

- Doug




"john" <puopolo@gmail.com> wrote in message
news:1165160006.502441.322460@n67g2000cwd.googlegroups.com...
> All:
>
> I have been developiing a simple (what I thought was simple) custom
> control (derived from UserControl). The basic functionality is that of
> a Jeopardy-style game square --- it should be a rounded rectangle that
> is filled with a gradient brush that sizes itself to the grid cell
> (parent) to which it is placed.
>
> What I have learned...
>
> * A UserControl can only have one child element. I originally used a
> Rectangle, but then could not add the question/answer text (no way to
> add a Label or TextBlock, etc.). Laurent Bugnion suggested using a
> container for the single allowed child and add children this way. I
> tried this and used a Canvas - it worked, somewhat...
>
> * I added 2 children to the Canvas -- a rectangle and a TextBlock.
> Originally, the rectangle was marked as
> Horizontal/VerticalAlignment="Stretch", with no specific Width and
> Height specified. This worked when the Rectangle was the direct child
> of the UserControl - but failed to display when the Rectangle was the
> child of the Canvas. Apparently, the Rectangle needs to have a specific
> Width and Height specified - which prevents Stretch from working...
> aaaarrrggghhhh
>
> Any insights and comments welcome. I hope the above helps others..
>
> John - jpuopolo
>


My System SpecsSystem Spec
Old 12-03-2006   #4 (permalink)
john
Guest


 

Re: Customer Control Lessons Leaned So Far...

Doug:

Thanks for the advice -- a StackPanel seems to do the trick... My only
challenge now is to figure out if it is possible to round the corners
of the StackPanel -- will play around with various configurations and
post the results.

Best,
John (jpuopolo)


Douglas Stockwell wrote:
> Hi John,
>
> Canvas is only used for absolute positioning, that is, where you specify
> Left, Top, Width and Height properties. Horizontal/VerticalAlignment are
> unused.
>
> I think you just need to explore the other subclasses of
> System.Windows.Controls.Panel, depending on how you want to lay out the
> elements, at least one of (or a combination of) Grid, StackPanel, WrapPanel,
> or DockPanel should suit your needs.
>
> - Doug
>
>
>
>
> "john" <puopolo@gmail.com> wrote in message
> news:1165160006.502441.322460@n67g2000cwd.googlegroups.com...
> > All:
> >
> > I have been developiing a simple (what I thought was simple) custom
> > control (derived from UserControl). The basic functionality is that of
> > a Jeopardy-style game square --- it should be a rounded rectangle that
> > is filled with a gradient brush that sizes itself to the grid cell
> > (parent) to which it is placed.
> >
> > What I have learned...
> >
> > * A UserControl can only have one child element. I originally used a
> > Rectangle, but then could not add the question/answer text (no way to
> > add a Label or TextBlock, etc.). Laurent Bugnion suggested using a
> > container for the single allowed child and add children this way. I
> > tried this and used a Canvas - it worked, somewhat...
> >
> > * I added 2 children to the Canvas -- a rectangle and a TextBlock.
> > Originally, the rectangle was marked as
> > Horizontal/VerticalAlignment="Stretch", with no specific Width and
> > Height specified. This worked when the Rectangle was the direct child
> > of the UserControl - but failed to display when the Rectangle was the
> > child of the Canvas. Apparently, the Rectangle needs to have a specific
> > Width and Height specified - which prevents Stretch from working...
> > aaaarrrggghhhh
> >
> > Any insights and comments welcome. I hope the above helps others..
> >
> > John - jpuopolo
> >


My System SpecsSystem Spec
Old 12-03-2006   #5 (permalink)
john
Guest


 

Re: Customer Control Lessons Leaned So Far...

Doug:

Thanks for the advice -- a StackPanel seems to do the trick... My only
challenge now is to figure out if it is possible to round the corners
of the StackPanel -- will play around with various configurations and
post the results.

Best,
John (jpuopolo)


Douglas Stockwell wrote:
> Hi John,
>
> Canvas is only used for absolute positioning, that is, where you specify
> Left, Top, Width and Height properties. Horizontal/VerticalAlignment are
> unused.
>
> I think you just need to explore the other subclasses of
> System.Windows.Controls.Panel, depending on how you want to lay out the
> elements, at least one of (or a combination of) Grid, StackPanel, WrapPanel,
> or DockPanel should suit your needs.
>
> - Doug
>
>
>
>
> "john" <puopolo@gmail.com> wrote in message
> news:1165160006.502441.322460@n67g2000cwd.googlegroups.com...
> > All:
> >
> > I have been developiing a simple (what I thought was simple) custom
> > control (derived from UserControl). The basic functionality is that of
> > a Jeopardy-style game square --- it should be a rounded rectangle that
> > is filled with a gradient brush that sizes itself to the grid cell
> > (parent) to which it is placed.
> >
> > What I have learned...
> >
> > * A UserControl can only have one child element. I originally used a
> > Rectangle, but then could not add the question/answer text (no way to
> > add a Label or TextBlock, etc.). Laurent Bugnion suggested using a
> > container for the single allowed child and add children this way. I
> > tried this and used a Canvas - it worked, somewhat...
> >
> > * I added 2 children to the Canvas -- a rectangle and a TextBlock.
> > Originally, the rectangle was marked as
> > Horizontal/VerticalAlignment="Stretch", with no specific Width and
> > Height specified. This worked when the Rectangle was the direct child
> > of the UserControl - but failed to display when the Rectangle was the
> > child of the Canvas. Apparently, the Rectangle needs to have a specific
> > Width and Height specified - which prevents Stretch from working...
> > aaaarrrggghhhh
> >
> > Any insights and comments welcome. I hope the above helps others..
> >
> > John - jpuopolo
> >


My System SpecsSystem Spec
Old 12-03-2006   #6 (permalink)
Laurent Bugnion
Guest


 

Re: Customer Control Lessons Leaned So Far...

Hi,

john wrote:
> Doug:
>
> Thanks for the advice -- a StackPanel seems to do the trick... My only
> challenge now is to figure out if it is possible to round the corners
> of the StackPanel -- will play around with various configurations and
> post the results.
>
> Best,
> John (jpuopolo)


Sure, use a Border:

<StackPanel>
<Border CornerRadius="10" BorderBrush="Red" BorderThickness="5">
<TextBlock Text="Hello" />
</Border>
</StackPanel>

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 12-03-2006   #7 (permalink)
Laurent Bugnion
Guest


 

Re: Customer Control Lessons Leaned So Far...

Hi,

john wrote:
> Doug:
>
> Thanks for the advice -- a StackPanel seems to do the trick... My only
> challenge now is to figure out if it is possible to round the corners
> of the StackPanel -- will play around with various configurations and
> post the results.
>
> Best,
> John (jpuopolo)


Sure, use a Border:

<StackPanel>
<Border CornerRadius="10" BorderBrush="Red" BorderThickness="5">
<TextBlock Text="Hello" />
</Border>
</StackPanel>

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminology lessons, please. davidjchuang Vista General 9 03-26-2008 05:02 PM
Default Customer Information RonM Vista General 1 11-15-2007 10:46 PM
Vista RC1 & RC2 Lessons learned so far. (May help the newbies) Gene Fitz Vista General 7 06-26-2007 07:49 PM
Vista's Lessons for Microsoft Tiberius Vista General 18 05-16-2007 11:38 AM
Customer Preview Impressions Mike Polinske Vista General 9 06-22-2006 03:27 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51