0

完全に機能する次の XAML があります (myRectConverter クラスと共に)。唯一の問題は、アプリケーションで動的に生成できるように、これを VB.NET コードに変換する必要があることです。

  <Canvas Grid.Column="0" Grid.Row="0" Height="{Binding ElementName=FeatureOverlay1, Path=ActualHeight}" HorizontalAlignment="Stretch" Name="Canvas1" VerticalAlignment="Stretch" Width="{Binding ElementName=FeatureOverlay1, Path=ActualWidth}" Background="Red">
    <Canvas.Clip>
      <RectangleGeometry x:Name="clipRect" RadiusX="5" RadiusY="5">
        <RectangleGeometry.Rect>
          <MultiBinding Converter="{StaticResource myRectConverter}">
            <Binding ElementName="Canvas1" Path="Width"/>
            <Binding ElementName="Canvas1" Path="Height"/>
          </MultiBinding>
        </RectangleGeometry.Rect>
      </RectangleGeometry>
    </Canvas.Clip>
    <Image Canvas.Left="0" Canvas.Top="0" Name="TestImage" Stretch="Fill" Source="/FluidSize;component/Images/Desert.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  </Canvas>

これが私がこれまでに持っているものです:

Dim rectGeometry As RectangleGeometry = New RectangleGeometry

rectGeometry.RadiusX = 5
rectGeometry.RadiusY = 5

Dim multiBinding As MultiBinding = New MultiBinding()
multiBinding.Converter = New RectConverter

Dim binding As Binding = New Binding()
binding.ElementName = "Canvas1"
binding.Path = New PropertyPath("Width")
multiBinding.Bindings.Add(binding)

binding = New Binding()
binding.ElementName = "Canvas1"
binding.Path = New PropertyPath("Height")
multiBinding.Bindings.Add(binding)

' Need to somehow add the multibinding object to the rectGeometry as a Rect structure, then assign to Canvas1.Clip

これを機能させる方法を知っている人はいますか?

ありがとう

ベン

4

1 に答える 1

1
BindingOperations.SetBinding(rectGeometry, RectangleGeometry.RectProperty, multiBinding);

または:

rectGeometry.SetBinding(RectangleGeometry.RectProperty, multiBinding);
于 2011-01-02T09:30:36.600 に答える