- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我什么时候从 UIElement
派生和 FrameworkElement
考虑 FrameworkElement
继承 UIElement
.任何人都可以举出现实生活中的例子吗?
最佳答案
This is a good page for learning about WPF Architecture ,此答案仅适用于 WPF。如果您有时间,请查看 UIElement
和 FrameworkElement
部分以及其余部分。这是来自链接页面的引述,解释了为什么存在 2 个级别:
To this point in the topic, "core" features of WPF – features implemented in the PresentationCore assembly, have been the focus. When building WPF, a clean separation between foundational pieces (like the contract for layout with Measure and Arrange) and framework pieces (like the implementation of a specific layout like Grid) was the desired outcome. The goal was to provide an extensibility point low in the stack that would allow external developers to create their own frameworks if needed.
UIElement
知道如何绘制自己(因为它们是从 Visual 派生的)。他们还可以通过提供
OnPreviewMouseDown
和
OnMouseDown
等虚拟方法来使用
routed events system,并通过实现
Measure
和
Arrange
来使用
layout system 的一部分。
FrameworkElement
通过实现
UIElement
中定义的一些虚拟方法来扩展布局系统。它们提供了设置布局属性的一致方式,例如
Margin
属性和
MinWidth
属性。此外,可以设置样式,并且可以参与
data binding 。
FrameworkElement
添加的任何额外功能,例如您需要更易于使用的样式、绑定(bind)或布局系统,然后从中派生。否则,从
UIElement
派生,因为使用
FrameworkElement
会有一点开销。
Control
类(派生自
FrameworkElement
),因为它们提供了有用的新功能层,如
Templating 和属性,如
Padding
。
Visual
更高的链)。
关于wpf - WPF/Silverlight 中的 UIElement 与 FrameworkElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5956880/
我是 Silverlight 编程的新手。谁能告诉我两者之间的区别 FrameworkElement obj=sender as FrameworkElement 和 FrameworkElement
在对 Cannot find governing FrameworkElement or FrameworkContentElement for target element 错误进行了一些研究后,我
我试图在构造函数中设置Page的Name属性: public partial class PageListView : Page { public PageListView(string ti
试图让 OnMouse 事件出现在 child 身上 FrameworkElement .父元素是 Panel (并且 Background 属性不是 Null)。 class MyFramework
我们有一个派生自 FrameworkElement 且不受我们控制的类。此类在 OnInitialize 中注册事件处理程序方法。 由于 FrameworkElement 不提供与 OnInitial
我一直在通过 Sells/Griffiths 的“Programming WPF”自学 WPF,我发现它是一个很好的资源,但我正在尝试采用他们向我介绍的一些概念并开始更进一步,我遇到了关于如何将各个部
我正在使用我在 http://brianlagunas.com/wpf-copy-uielement-as-image-to-clipboard/ 找到的一些代码复制呈现的 XAML Treeview
我不清楚您何时会使用 UIElement而不是 FrameworkElement ,以及为什么会有 FrameworkElement根本没有课。本质上,FrameworkElement 的额外功能是什
我正在尝试在使用 Uno 构建的 WebAssembly 应用程序中创建文件对话框。我添加了一个自定义 FrameworkElement 来创建 在页面中像这样: [HtmlElementAttrib
我收到了 FrameworkElement在类的事件处理程序中。是否有可能检查这个 FrameworkElement是具有 borderthickness/borderbrush 属性的元素吗? 喜欢
根据文档“(FrameworkElement.SizeChanged) 当此元素上的 ActualHeight 或 ActualWidth 属性值更改时发生。” 运行以下测试方法,我的矩形的 Actu
每个 FrameworkElement 都有一个 Loaded 事件,该事件在以下情况下触发: the tree is not only built and initialized, but layo
您能否举例说明如何创建直接从 FrameworkElement 派生的自定义复合控件(在 Silverlight 4 中)。这是一个模型: public sealed class CompositeI
我有一棵视觉树。主窗口有一个全尺寸的 Canvas 。 Canvas 包含一些自定义视觉对象的根。第一个自定义 Visual (A) 可以根据用户正在查看的内容进行扩展和收缩,这些内容位于子项中(Bs
是否可以识别哪个窗口/用户控件拥有 FrameworkElement ? 谢谢你。 最佳答案 您可以使用 .Parent “走上去” - 属性,直到找到窗口或用户控件。只需在向上走时检查 parent
我有一个 FrameworkElement(实际上是一个 ToggleButton),其内容中有一个 Popup。 我是这样访问的: ToggleButton button = (ToggleButt
我正在尝试自定义绘制 GridSplitter,并且我有以下 XAML 代码: DiffSplitterCanva
如何获取框架元素边界矩形的左上角坐标? let fe : FrameworkElement = ea.Item.Content let p = fe.TranslatePoint(ne
对于 WPF,Window 类中有一个 ContentRendered 事件,它让我们知道视觉元素何时被渲染。 有什么可以帮助我为 UWP 应用实现相同的结果吗?我想知道 FrameworkEleme
我的一个数据源生成一组值,这些值被输入到以下接口(interface) public interface IData { string Name { get; } FrameworkE
我是一名优秀的程序员,十分优秀!