问题标签 [uielement]

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 投票
1 回答
7075 浏览

c# - WPF FrameworkElement 父级和移动 UIElement

我正在尝试将控件从一个父级移动到另一个父级(如果这可行,我不太确定)。我可以抓住我想要移动的控件。这是我的代码:

当我点击最后一条语句时,会引发 ArgumentException,说明“指定的视觉对象已经是另一个视觉对象的子对象或 CompositionTarget 的根”。奇怪的是,Parent 正在返回 null。如何找到父级?这甚至会起作用吗?

编辑:我不认为实际移动元素是我问题的答案。我正在使用 Visual Studio SDK,并且能够掌握UIElement构成编辑器窗格(扩展DockPanel)的内容。我试图将控件从标准编​​辑器移动到我正在开发的自定义工具窗口中。

这被证明是一个 hack,我意识到我需要同一个控件的多个实例,所以我认为一个更复杂的解决方案(和更少的 hack)正在存储中。

0 投票
1 回答
168 浏览

wpf - UiElement based on another class

I placed a control into a grid. let's say the control is derived from public class 'ButBase' which is derived in its turn from System.Windows.Controls.Button. The code normally compiles and app works just fine. But there's something really annoying.

When you try to switch to xaml-design tab it will say 'The document root element is not supported by the visual designer', which is normal and I'm totally okay with that, but the thing is, that all the xaml code is underlined and VS2010 says: 'Cannot create an instance of ButBase' although still normally compiles and able to run.

I've tried the same code in VS2008, it said that needs to see a public parameterless constructor in the ButBase, and even after I put one it showed the same error.

What do I miss here?

0 投票
2 回答
348 浏览

silverlight - 为什么我的 Silverlight UIElements 没有 OnPreview 事件?

我正在构建一个自定义 Silverlight UserControl,它需要使用预览/隧道来监听事件,但由于某种原因,编译器告诉我它们无法识别或无法访问。

例如,我可以将事件处理程序添加到MouseLeftButtonDown,但不能PreviewMouseLeftButtonDown。这没有意义,因为根据微软(http://msdn.microsoft.com/en-us/library/system.windows.uielement_members(v=VS.100).aspx),所有UIElements 都应该附加 Preview 事件。

关于为什么会发生这种情况的任何想法?我正在使用 Visual Studio 2010 试用版、Blend 4 RC 和 .Net 4,如果这有所作为的话。

0 投票
4 回答
3485 浏览

image - Silverlight 4 - 将 UIElement 渲染为图像

我有一个UIElement我想捕获用户单击按钮时的快照。当用户单击按钮时,我想将UIElement其当前状态加载到 Image 元素中。如何将 a 渲染UIElementImage

0 投票
1 回答
887 浏览

wpf - WPF Checkbox 不会将 UIElement 显示为其内容

我正在使用自定义复选框,并且正在尝试将内容设置为 WPF Viewbox。问题是,简单地说,什么都没有显示。该复选框出现并有效,但它没有内容。这是我正在尝试做的示例代码(不是实际代码)。

Content 属性接受一个对象,因此将其设置为 Viewbox 是没有问题的,并且 ContentPresenter 可以显示一个 UIElement。我想也许 ContentPresenter 无法显示 Viewbox 中包含的标签,所以我创建了一些测试代码,将复选框的内容设置为简单的矩形。依然没有。

有什么想法或想法吗?谢谢你的帮助!

哦 - 将 Content 属性设置为字符串有效。

0 投票
2 回答
9017 浏览

c# - 使用 C# 来自 UIElement 的 WPF 屏幕截图 JPG

我正在尝试从我的 WPF 应用程序的一部分创建 JPG。像截图一样,只有个别UIElement的。我从这里开始:http: //www.grumpydev.com/2009/01/03/taking-wpf-screenshots/

我正在使用他的扩展方法,这使您可以使用UIElement.GetJpgImage(). 然后可以使用文件流将其写入 JPG 图像。如果我制作整个窗口的 JPG,它看起来就好了!然而,这并不理想,因为它只是捕捉用户所看到的。由于滚动查看器或因为它们的父级被动画到小尺寸而不可见的东西不会显示出来。

如果我对用于布局的网格进行“截图”: alt text http://img697.imageshack.us/img697/4233/fullscreenshot2.jpg

我得到这个带有黑色背景的废话。我不想要那个。此外,如果我使用动画折叠了这个网格的高度,我将一无所获。这些实际上是模板化的复选框,它们上面应该有黑色文本,并且网格的背景应该是白色的。这是其他人编写的用于返回写入文件流的 byte[] 数组的代码:

在那里的某个地方,我们得到了一个黑色的背景。有什么见解吗?

编辑:如果我将网格的背景属性设置为白色,屏幕截图会按预期出现。但是,设置我需要截屏的所有背景是不可行的。

0 投票
2 回答
232 浏览

silverlight - 在替换动画的 UIElements 时如何提高 Silverlight WritableBitmap 的质量

我正在制作一个动画,我暂时降低UIElements 和覆盖WritableBitmap原始版本的可见性Image

我遇到的问题是,当我在带有文本的元素上执行此操作时,会导致图像明显模糊和变暗,这意味着从UIElementto的切换Image很明显。

有没有人经历过这个和/或知道如何处理这个问题?

0 投票
2 回答
127 浏览

wpf - 是否有任何解决方法可以在 WPF 中的一个 UIElement 上应用多个效果?

是否有任何解决方法可以UIElement在 WPF 中对一个效果应用多个效果?例如

提前致谢。

0 投票
1 回答
2135 浏览

iphone - 如何将多个 UIElement(uilabel、uiimageview 等)堆叠/z 定位在彼此之上?

我的屏幕上有几个 UI 元素(以编程方式),我需要一种有效的方法来为每个子视图提供 z-index 设置,这样我就可以将某些元素堆叠在其他元素之上。

有人对此有解决方案吗?

0 投票
2 回答
2702 浏览

c# - UIElement 在运行时的转换错误

执行此操作时出现运行时错误。

我有这个类:

当我这样做时,它编译得很好,但会引发运行时错误......

我得到的错误是无法将 AnnObject 转换为UIElement.

有人可以简要解释一下这种行为吗?