RatioPanel children will be instances of ContentPresenter, assuming elements are not UIElements. ContentPresenter displays the DataTemplate that you defined in the ItemTemplate.
Usually panels work directly with their children. You set your attached property to the ContentPresenter child, which is the child of your panel. I believe that you should install this directly in ContentPresenter. So something like this:
<ItemsControl.ItemContainerStyle> <Style> <Setter Property="wpflib:RatioPanel.Ratio" Value="{Binding Path=Value}" /> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> <Rectangle x:Name="RatioShape" Fill="{Binding Path=Brush}" /> </DataTemplate> </ItemsControl.ItemTemplate>
source share