WPF VB.NET RectangleGeometry 矩形结构多重绑定
我有以下可以完美运行的 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
有人知道如何让它工作吗?
谢谢
本
I have the following XAML which works perfectly (along with the myRectConverter class). The only problem is I need this to be converted into VB.NET code so it can be produced in the application dynamically.
<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>
Here is what I have so far:
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
Does anyone know how to get this working?
Thanks
Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者:
Alternatively: