0

Here is my specific problem:

Xaml:

<local:ShrinkableContentControl x:Name="m_ShrinkableContentControl">
    <Border Background="SkyBlue">
        <Button Click="Button_Click_1" Content="Hello"/>
    </Border>
</local:ShrinkableContentControl>

Code for ShrinkableContentControl:

[ContentProperty("Shrinkable")]
public class ShrinkableContentControl : FrameworkElement
{
    protected override Size MeasureOverride(Size availableSize)
    {
        return base.MeasureOverride(availableSize);
    }

    protected override Size ArrangeOverride(Size finalSize)
    {
        this.Shrinkable.Arrange(new Rect(0, 0, 100, 100));
        return base.ArrangeOverride(finalSize);
    }

    public FrameworkElement Shrinkable { get; set; }
}

The issue here is, Shrinkable is Content, and is not added in to the visualtree, so nothing gets displayed.

Can anyone tell me if there is a way to add the Shrinkable as a child of ShrinkableContentControl in the visualtree?

Thanks, Henry

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
ryhzhang
  • 92
  • 1
  • 4
  • Just to follow up on the question. I don't want to use a Panel. I want to force only a single Child. – ryhzhang Sep 19 '10 at 01:46

1 Answers1

2

If you want a single child, it sounds like you should inherit from ContentControl:

Represents a control with a single piece of content of any type.

Just set the Content property

Rob Fonseca-Ensor
  • 15,510
  • 44
  • 57