本文介绍了在WPF programmaticaly透明边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它是微不足道的生成边界(用于轨迹球事件)透明了在XAML文件中视:
Its is trivial to generate a border (to use for Trackball events) transparent over the viewport in the XAML file:
<Border Name="myElement" Background="Transparent" />
但我怎么做它在的.cs?
But how do I do it in the .cs?
Border border = new Border();
**border.Background = (VisualBrush)Colors.Transparent;**
grid.Children.Add(viewport);
grid.Children.Add(border);
这不,当然工作...
This does not work of course...
谢谢,
佩德罗Dusso
推荐答案
这是因为你不能只是投出彩是一个刷机。使用刷代替
This is because you can't just cast a Color to be a Brush. use the Transparent brush instead
border.Background = Brushes.Transparent;
这篇关于在WPF programmaticaly透明边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!