2

ItemsControlUserControl としてテンプレート化された項目があります。MyItemsControl.Items Panelは としてテンプレート化されていCanvasます。


今のところ、これらのユーザーコントロールの幅と高さのプロパティを手動で設定すると、次のようになります。

<ItemsControl x:Name="curveList"
              ItemsSource="{Binding SplineVMList}"
              Background="{x:Null}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Canvas x:Name="canvas" Margin="46,60,83,46"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <local:SplineControl Width="300" Height="300" Canvas.Bottom="0" Canvas.Left="0" IsSelected="{Binding IsSelected, Mode=TwoWay}"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
    <ItemsControl.ItemContainerStyle>
        <Style TargetType="ContentPresenter">
            <Setter Property="Canvas.Bottom" Value="0"/>
            <Setter Property="Canvas.Left" Value="0"/>
        </Style>
    </ItemsControl.ItemContainerStyle>
</ItemsControl>



私が欲しいのは、ユーザーコントロールの幅と高さのプロパティをキャンバスのプロパティにバインドすることです。それは可能ですか?

4

1 に答える 1

0

相対ソースバインディングを試しましたか?

例えば

Width="{Binding ActualWidth,
                RelativeSource={RelativeSource AncestorType=Canvas}}"
于 2012-07-23T04:41:15.543 に答える