0

我想知道如何将我的转换器分配给ConvertPoint祖先中调用的成员Viewport

<DataTemplate DataType="{x:Type local:TestShape}">
    <DataTemplate.Resources>
        <RelativeSource AncestorType="{x:Type root:Viewport}" x:Key="Viewport"/>
        <root:BezierScaleConvertor x:Key="BezierScaleConvertor" />
    </DataTemplate.Resources>
    <control:TestShape>
        <control:TestShape.StartPoint>
            <MultiBinding Converter="???"> <----------- Here I don't know how to refer to the member ConvertPoint which is a convertor in Viewport, if I use dynamicResource or Binding, it will raise an exception because it's not a DP.
                <Binding Path="StartPoint" />
                <Binding Path="ScaleX" RelativeSource="{StaticResource Viewport}"/>
                <Binding Path="ScaleY" RelativeSource="{StaticResource Viewport}" />
            </MultiBinding>
        </control:TestShape.StartPoint>
        <control:TestShape.Segments>
            <MultiBinding Converter="{StaticResource BezierScaleConvertor}">
                <Binding Path="Segments" />
                <Binding Path="ScaleX" RelativeSource="{StaticResource Viewport}" />
                <Binding Path="ScaleY" RelativeSource="{StaticResource Viewport}" />
            </MultiBinding>
        </control:TestShape.Segments>
    </control:TestShape>
</DataTemplate>
4

1 回答 1

0

我终于把它弄出来了。

要 100% 使这个 cas 工作,你应该使用 c# 代码版本的数据模板。

就这样。

于 2013-06-05T20:47:52.537 回答