我有一个情况,需要创建一个带有一个按钮的视图框(View box)。以下是此功能的XAML代码,请注意View box的Width属性。根据滑动条的移动(向右移动增加宽度,向左移动减小宽度),Width应该增加/减少。如下所示,我知道如何在XAML中实现它并且可以正常工作。但我的要求是能够在代码后台创建View box并分配它的属性。
<WrapPanel x:Name="_wrpImageButtons" Grid.IsSharedSizeScope="True"
ScrollViewer.CanContentScroll="True" d:LayoutOverrides="Height"
Margin="5">
<Viewbox x:Name="_ScaleButton"
Width="{Binding Value, ElementName=ZoomSlider}" Stretch="Fill">
<CustomButton:_uscVCARSImagesButton x:Name="_btnImage1"/>
</Viewbox>
</WrapPanel>
感谢您的选择。
BindingOperations.SetBinding
。 - H.B.