TextBox를 기반으로 CustomControl의 스타일을 수정하려고 시도했지만, 대부분 성공적으로 수행되었습니다. 내가 성취하려고 시도하는 것은 장애가있을 때 희미 해지는 것입니다. 이 작업을 성공적으로 수행했지만 색상이 해제되어 있으면 비활성화 된 표준 텍스트 상자와 일치하지 않습니다.기본 스타일 (텍스트 상자)보기
네이티브 TextBox에 적합한 색상은 무엇이며 적절한 구문을 복사하려면 기본 TextBox의 기본 스타일에 어떻게 액세스 할 수 있습니까? MSDN의 예제가 표준 스타일로 보이지 않습니다? Blend를 사용하여 기본 스타일을 잡아라는 제안을 보았습니까? 그 중 하나가 작동하지 않는 것, 어떤 이유로이 접근 방식은 내 프로젝트의 PresentationFramework.Classic에 대한 참조를 생성하고 Windows Forms (침몰 한 테두리 등)처럼 보이는 TextBox를 제공합니다.
generic.xaml을
<Style x:Key="{x:Type l:CustomTextBox}" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type l:CustomTextBox}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type l:CustomTextBox}">
<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer x:Name="PART_ContentHost" Margin="2" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<!-- The background does change, but the color does not match native disabled TextBoxes. -->
<Setter Property="Background" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<!-- Additional triggers, none of which modify the Background. -->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
http://stackoverflow.com/a/4195375/815938 – kennyzx