构造函数,它是Object类的一部分(Constructor which is a part of Object class)
我正在阅读有关构造函数的JLS ,并遇到以下内容:
如果构造函数体不以显式构造函数调用开头,并且声明的构造函数不是 原始类Object的一部分
事情是我无法想象如何声明构造函数可以成为类Object的一部分? 你能提供一个例子吗?
I was reading JLS about constructors and came across the following:
If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object
The thing is I can't imagine how is constructor being declared can be a part of the class Object? Could you provide an example?
原文:https://stackoverflow.com/questions/26826959
最满意答案
把拼图的各个部分拼凑在一起
AdornerLayer表示用于渲染装饰者的表面。 由于
AdornerLayer
通常提供整个视图,而不仅仅是一个控件,因此默认情况下某些容器会实现它们。装饰器是绑定到
UIElement
的自定义FrameworkElement
。 Adorner在AdornerLayer中呈现,AdornerLayer
是一个始终位于装饰元素或装饰元素集合之上的渲染表面。因此,在这种情况下,adorner(红色矩形)绑定到
TextBox
,但是在TextBox
顶部的图层中呈现。通过调用静态方法
GetAdornerLayer
来获取装饰的UIElement
的AdornerLayer
对象来完成装饰(例如,在验证错误的情况下)。足够的理论
更改
TabItems
会丢弃AdornerLayer
,导致不会绘制装饰器。 2个修复:\手动方式,由DRapp提出:
<XAML for MyView1> <AdornerDecorator> ... </AdornerDecorator> </close XAML for MyView1>
当然,如果在
AdornerDecorator
和TextBox
(在可视化树中)有另一个容器实现AdornerLayer
,这将没有任何好处。 因此显式的AdornerDecorator
需要是包装TextBox
的最后一个。<XAML for MyView1> <Grid> ... <GroupBox> <AdornerDecorator> <Grid> ... <TextBox ... /> </Grid> </AdornerDecorator> </GroupBox> </Grid> </close XAML for MyView1>
\第二个解决方案(我更喜欢)每次
TextBox
变得可见时重置ErrorTemplate 。 这样做可以发现并修复AdornerLayer
的缺失。<UserControl.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="IsVisible" Value="true"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </UserControl.Resources>
Putting together the pieces of the puzzle
An AdornerLayer represents a surface for rendering adorners. As an
AdornerLayer
usually serves an entire view, not just one control, some containers implement them by default.An adorner is a custom
FrameworkElement
that is bound to aUIElement
. Adorners are rendered in anAdornerLayer
, which is a rendering surface that is always on top of the adorned element or a collection of adorned elements.So in this case the adorner (red rectangle) is bound to a
TextBox
, but is rendered in a layer on top of theTextBox
.Adorning (e.g. in case of a validation error) is done by calling the static method
GetAdornerLayer
to get anAdornerLayer
object for theUIElement
to be adorned.Enough theory
Changing
TabItems
discards theAdornerLayer
, resulting in the adorner not being drawn. 2 fixes:\The manual way, as proposed by DRapp:
<XAML for MyView1> <AdornerDecorator> ... </AdornerDecorator> </close XAML for MyView1>
Of course, if there's another container implementing an
AdornerLayer
between theAdornerDecorator
and theTextBox
(in the visual tree), this won't do any good. So the explicitAdornerDecorator
needs to be the last one wrapping theTextBox
.<XAML for MyView1> <Grid> ... <GroupBox> <AdornerDecorator> <Grid> ... <TextBox ... /> </Grid> </AdornerDecorator> </GroupBox> </Grid> </close XAML for MyView1>
\Second solution (which I prefer) resetting the ErrorTemplate each time the
TextBox
becomes visible. In doing so the lack ofAdornerLayer
gets spotted and fixed.<UserControl.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="IsVisible" Value="true"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </UserControl.Resources>
相关问答
更多-
我怀疑,这是由于错误模板在adorner层上呈现,因此它不会影响窗口的布局。 请参阅: http : //social.msdn.microsoft.com/Forums/en-US/wpf/thread/9de3c9e5-5759-4f88-9184-175d3eaabdad/ 我现在正在使用此控件模板: -您显然可以将AdornerElementPlaceholder的可见性绑定到装饰器自身的可见性。 这是我的代码:我自己解决了。 解决方案只是一个ControlTemplate ,其中ImageSource和BorderBrush绑定到UserGroup-Property,并且决定在两个转换器中完成。 ControlTemplate看起来像:
如何在Validation.ErrorTemplate中找到ErrorContent(how to find ErrorContent in Validation.ErrorTemplate)[2022-10-05]
我改变了我的风格: You should define your new style based on existing to keep everything it has. I gue ...在UserControl中绑定Validation.ErrorTemplate(Binding Validation.ErrorTemplate in UserControl)[2022-05-23]
查看Validation.ErrorTemplate MSDN页面 ,您可以看到它将IsNotDataBindable元数据属性设置为true ,因此很遗憾您无法将数据绑定到该属性。 我相信您仍然可以使用Validation.SetErrorTemplate()来处理依赖项属性的OnChanged事件以自行设置该属性: public static readonly DependencyProperty ValidationTemplateProperty = DependencyProperty.R ...相关文章
更多- Object Oriented Programming
- Solr的自动完成实现方式(第一部分:facet方式)
- Guava学习笔记:复写的Object常用方法
- jQuery的validate插件使用整理(第一部分:HelloWorld)
- 7.trouble is a friend(Lenka)
- 了解 Web Part 框架
- Solr: a custom Search RequestHandler
- Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案
- Spring Data: a new perspective of data operations
- java反射详解(一)_Class类
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。