views:

50

answers:

1

Hi,

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

+1  A: 

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