问题标签 [visualbrush]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2388 浏览

wpf - 使用 Canvas 作为具有可绑定颜色的图标

尽可能多WPF,我使用这种模式来创建一个矢量图标:

1 - 定义 aCanvas包含数据:

资源项目

2 - 在控制模板中使用它:

控制模板

whichui:UIElement.VisualIcon属性是一个附加属性,用于告诉模板使用哪个资源。例如:

现在,如您所见,我必须获取PathaCanvasFill

问题是,是否可以将Fill值绑定到某个东西 on TemplatedParent?例如,我有一个附加属性来持有图标画笔:

我试着像下面这样使用它:

但它不起作用。你有什么想法吗?我的意思是绑定资源项的某些属性以设置它们将被使用的位置?- 英语不好,我知道,对不起:(

0 投票
1 回答
637 浏览

wpf - 为什么在 VisualBrush 中设置 Stretch 属性时不应用 Ellipse 的填充?

我正在开发一个自定义控件,并且我有一个这样VisualBrushVisual属性:

Stretch属性设置为Uniform而不是使用RadialGradientBrush我创建的时,它会以某种方式SolidColorBrush使用Stroke颜色创建一个。但是,当我明确设置WidthHeight的属性Ellipse而不是使用该Stretch属性时,我得到了我期望的渐变。

有什么奇怪的想法吗?

Ellipse编辑:我刚刚观察到当我将ViewBox.

0 投票
0 回答
1561 浏览

wpf - WPF Visualbrush 到 Imagesource

我想将 VisualBrush 保存到文件中。我尝试了许多不同的解决方案,但没有任何效果。我试图写一个简单的转换器:

总而言之,结果是黑色图像。但是,如果我将源画笔更改为 Brushes.Red 之类的东西,则结果是红色图像。所以我猜想对位图的渲染失败,但保存到文件是有效的。

有谁知道我做错了什么?

0 投票
2 回答
169 浏览

c# - 使用线性渐变获取矩形中偏移处的颜色

我有一个带有以下 XAML 的矩形:

我需要一个代码解决方案,当给定从 1 到 100 的输入偏移量时,可以从 ActiveIndex 中找到颜色。

目前,我正在使用另一个带有 Viewbox 的绑定 Rectangle 通过设置 Viewbox 左值以适应偏移量来显示颜色。这种方法不会让获取颜色,因为画笔是视觉画笔。

0 投票
1 回答
322 浏览

c# - 为什么基于网格的可视画笔显示水平和垂直网格线

如果您测试下面的代码和任何明亮的图像,您将看到 4 列和 4 行绘制在使用的图像上。我需要这个配置来达到某种效果。基本上我做到了,它可以工作,但是我想删除这些网格线,但不知道如何删除。它可能与 Grid 控件本身的实现有关吗?Grid 的属性 ShowGridlines 为 false。

有可能使用画布而不是网格并手动进行放置,但我想保留网格并将画布用作最后的解决方案。

0 投票
1 回答
808 浏览

wpf - 在 WPF 中具有淡入淡出边距的 VisualBrush

我正在尝试创建一个VisualBrush带有阴影图案的图案,该图案会在顶部和底部边缘褪色。虽然我对孵化本身没有问题:

我真的没有办法让它褪色。知道怎么做吗?

尝试按照下图获取背景。

在此处输入图像描述

0 投票
1 回答
456 浏览

c# - 在 WPF 中为 VisualBrush 设置边界

有一个蓝色矩形填充了自定义VisualBrush(左图)。一条线穿过矩形。如何修剪画笔以实现正确图像中的形状。

在此处输入图像描述

0 投票
1 回答
1610 浏览

c# - VisualBrush WPF displaying

I have a canvas that consists of different UserControls in WPF/XAML. In one of these controls I have a region that has to be transparent so the elements behind it are visible. However, due to the complex structure of this control I cannot just set the background to transparent or anything because there is another element in that usercontrol that is lets say moving behind it and cannot be transparent. So I want to have a region that seems transparent eventhough there is something else still behind it.

The only thing I could come up with is to use a VisualBrush and display exactly that region of my canvas on top of the region that has to look like if it was transparent. I wanted to do this in WPF and not XAML since I need to adjust the viewbox exactly so that the content is exactly the content that is behind that part. However, this does not seem to work at all. Here is the WPF code:

BorderTest is the border that I defined in the xaml code that has to be transparent (it has a certain width and height). I did not set the viewbox properties yet since this is already not working. I was expecting that at least some part of the canvas would already be displayed inside my "borderTest"... Someone has an idea of my problem or can point me to some code where they do similar stuff? I already found a lot on the internet but I cannot get this thing to work.

0 投票
1 回答
889 浏览

c#-4.0 - VisualBrush makes Visual blurred

i have a problem with the WPF VisualBrush. Here you find two images from my application. The bigger on is a image which shows a control with text. The smaller one is a extract from the first on who i use a visual brush to make it. My problem is, that when the resolution of my Visual (the content for VisualBrush) would be smaller then the visual brush looks more blurred. I don't no why. I use the following code to declare the visual brush.

Host.Viewer is the control you see it on the big image. Everytime the control size is changed i update the ViewBox values with the following routine:

topLeft is the start coordinates and the width and height values are the size of extract i needed. I hope anyone can help how i can prevent that the control would be blurry!

Thanks Daniel

0 投票
1 回答
357 浏览

c# - VisualBrush(链接到 VLC)在 TabControl 选择更改时不会更改

我对视觉画笔(通过 VLC.DotNet 链接到 VLC 播放器)和选项卡控件的组合有一种奇怪的体验。我使用 VLC 播放器创建了一个自定义控件来观看 RTSP 流,并在给定窗口中有多个这些控件。

问题是,如果我将所有控件放在列表视图中,它们都会正确显示。但是,如果我将它们放在选项卡控件中,那么它总是显示第一个选择的选项卡项的流,无论我当前在哪个选项卡上。控件中的其他所有内容(标签等)都会正确更改,但视觉画笔绘制的部分不会。

我的控件的视图定义为:

视图背后的代码开始播放 RTSP,但我认为该代码不会帮助解决这个问题。

同时,ViewModel(为了便于查看而精简)只是:

我有一个数据模板定义为:

完整的窗口视图模型有一个称为 Monitors 的 ObservableCollection,视图显示:

ListView 正确显示来自每个摄像头的不同图像。选项卡项将始终显示相同的相机,但当我单击不同的选项卡时,控件的标签项会发生变化。此外,如果我将 VLC 控件图像的数据绑定替换为注释掉的静态图像对象(其源是通过视图模型设置的),那么当我单击不同的选项卡时,图像将正确更改。

我真的很困惑,如果能提供任何帮助,我将不胜感激。