주로 사소한 편집이 있고 대부분 반복되는 스타일 요소가 있습니다. 내가 좀 더 일반적인 어떻게해야합니까 - 그래서 세터 속성 내에서 설정되는 모든 setter 속성은 여백과 폰트 크기를 제외하고 동일 코드에서 보듯이 두 번코드 재사용 가능 스타일
<ResourceDictionary>
<Style x:Key="TextBlockStyleEnvironment" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="5,4,0,0" />
<Setter Property="FontSize" Value="8" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style x:Key="TextBlockStyleLocation" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="5,4,0,0" />
<Setter Property="FontSize" Value="10" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</ResourceDictionary>
를 코드를 반복 대 값을 기준으로. 또한 렌더링시 스크린 샷이 첨부됩니다. 이 소모 될 때 XAML에서 지역 수준에서 선언이 스타일 (Style)에 포함이 자신을 유지하려는를하지 -
있습니다.
<Grid DataContext="{....}">
<StackPanel>
<TextBlock Text="{Binding Environment}" Style="{StaticResource TextBlockStyleEnvironment}"/>
<TextBlock Text="{Binding Location}" Style="{StaticResource TextBlockStyleLocation}"/>
여기서 가능한 해결책으로 MultiDataTriggers를 사용해야합니까? – Patrick