IT Share you

기본 스타일을 기반으로 스타일을 만드는 방법은 무엇입니까?

shareyou 2020. 11. 18. 21:48
반응형

기본 스타일을 기반으로 스타일을 만드는 방법은 무엇입니까?


Silverlight에서 기본 스타일을 기반으로 스타일을 만드는 방법은 무엇입니까?

예를 들어 WPF에서는 다음과 같이 만듭니다.

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
  <Setter Property="Margin" Value="2" />
  <Setter Property="Padding" Value="2" />
</Style>

거의 똑같애. x:Type더 명시적인 이름을 지정하여 빼기 만하면 됩니다.

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

자세한 내용은 여기 문서에 있습니다. 추신, 기본 템플릿이 필요한 경우 TextBox는 일반적으로 CoreStyles.xaml에서 찾을 수 있습니다.

답변을 처음 읽을 때 혼란 스러울 경우를 대비하여 주석에서 요청한 ADDENDUM;

" 기본 스타일이 필요합니다. 기본 스타일 은 ToolkitStyles.xaml과 같은 파일을 생성하는 기본적으로 제공되는 silverlight와 같은 애플리케이션 테마 (wpf / uwp 등에는 이러한 기능이 없음)에서 수행하기위한 것이므로 수행하기 매우 쉽습니다. , SDKStyles.xaml, CoreStyles.xaml 등 ... 답변의 정적 리소스 이름은 원래 답변 된 연도의 실버 라이트 버전을 대상으로 한 것입니다. "


기본 스타일을 기반으로 스타일을 만들려면 명명 된 스타일을 만든 다음 명명 된 스타일 ( http://weblogs.asp.net/lduveau/silverlight-how-to-inherit-from)을 기반으로 기본 스타일을 만들어야합니다 . -암시 적 스타일 )

<Style x:Key="DefaultCustomControlStyle" TargetType="local:CustomControl">
    <Setter Property="Padding" Value="2" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="local:CustomControl">
                <ContentPresenter />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
<Style TargetType="local:CustomControl" BasedOn="{StaticResource DefaultCustomControlStyle}" />

내가 올바르게 이해하면 OverridesDefaultStyle을 찾고 있습니다.

<Style TargetType="{x:Type TextBox}">
      <Setter Property="OverridesDefaultStyle" Value="False" />
      <Setter Property="Margin" Value="2" />
      <Setter Property="Padding" Value="2" />
</Style>

참고 URL : https://stackoverflow.com/questions/13016932/how-to-create-a-style-based-on-default-style

반응형