我如何在WPF反射作用? (从code) [英] How do I make a reflection effect in WPF ? (from code)
本文介绍了我如何在WPF反射作用? (从code)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在WPF一些镜子对象。我有一些内容的画布,我需要50个克隆的视觉,如果我修改源上的东西,它应该在这些克隆进行更新。
我知道这是很容易通过绑定一个可视化的VisualBrush的元素在XAML做的,但公司似乎可以从code做到这一点。
I need to have some mirror objects in WPF. I have a Canvas with some content, and I need 50 visual clones, and if I modify something on the source, it should be updated in these clones. I know it is easy to do in XAML by binding the Visual of a VisualBrush to the element, but can's seem to do this from code.
谁能帮助?
推荐答案
好吧,同时我已经找到了解决方案(通过涩涩)。如果有人有兴趣,下面找到它:
Ok, meanwhile I have found the solution (Via Sese). If anyone is interested, find it below:
VisualBrush VisualBrush1 = new VisualBrush();
VisualBrush1.TileMode = TileMode.FlipXY;
VisualBrush1.Viewport = new Rect(0.5, 0.5, 0.5, 0.5);
Binding bb = new Binding { ElementName = "button1" };
BindingOperations.SetBinding(VisualBrush1,VisualBrush.VisualProperty, bb);
rectangle1.Fill = VisualBrush1;
和在XAML:
<Grid>
<Button Height="39"
Margin="82,20,87,0"
Name="button1"
VerticalAlignment="Top">Button</Button>
<Rectangle Margin="82,56,87,0"
Name="rectangle1"
Height="37"
VerticalAlignment="Top">
</Rectangle>
</Grid>
也许你会发现这个有用的,
丹尼尔
Maybe you will find this usefull, Daniel
这篇关于我如何在WPF反射作用? (从code)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文