Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

.net - How to create a style based on default style?

How to create a style based on default style in Silverlight?

For example, in WPF we make it like:

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
  <Setter Property="Margin" Value="2" />
  <Setter Property="Padding" Value="2" />
</Style>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Pretty much the same. Just minus the x:Type with more explicit naming.

<Style TargetType="TextBox" BasedOn="{StaticResource DefaultTextBoxStyle}">

More information here in the docs. PS, in case you need the default templates, TextBox for example would normally be found in CoreStyles.xaml

ADDENDUM as requested in the comments in case you're confused at the first read of the answer;

"you DO need a base style, which is really easy to do as you're meant to do it in an application theme like silverlight provides by default (wpf/uwp etc won't have these) that creates the files like ToolkitStyles.xaml, SDKStyles.xaml, CoreStyles.xaml, etc... Which is WHERE the staticresource name in the answer came from as targeting a silverlight version from the year this was originally answered."


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...