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.
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
> 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" <email@example.com> wrote in message
> > 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