English 中文(简体)
纽约总部 4 - 从暗中清除财产(特别是模板)
原标题:Silverlight 4 - Explicit style clearing properties from implicit one (especially template)

如果我创设一个从<条码>中继承的类别,并形成一种含蓄的风格,将<条码>Template <条/条码>的财产与某种财产(单项事项)联系起来,那么我就会形成一种明确的风格,其中也规定了一种财产,请说<条码>Background,这就是为什么当我以明确的方式将XAML中的内容放在首位的时候。

So.. If I create a class as such: public class MyContentControl : ContentControl

形成一种含蓄的风格,将模板定在某件上(单单单是“条码”(<>)。

形成一种明确的“MyStyle”式,其编号为<Setter Property=“Background” Value=“Blue”/>

Then instantiate: <my:MyContentControl Style={StaticResource MyStyle} />

我在称作“OnApplyTemplate”之后看着我的控制,而<代码>Template<> /code> 财产反映了<代码>的模板,而不是我的模板。 如果我采取明确的做法,那就行得当。

This is confusing to me because the very same works with the Button class. I can create a Button style that does not set Template. I suppose it might have something to do with ButtonBase not having a template, but I m not sure what is causing this behavior.

我知道,我可以简单地看到我的模版,即我的模版,但我仍然对造成这种行为的原因感到奇怪,因此,请不要回答我。 这个问题完全是为了我的理解。

问题回答

暂无回答




相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签