为主题中的TextBlock样式设置ListViewItem的样式

时间:2018-11-19 22:18:59

标签: xaml listboxitem

似乎我需要使用主题中预定义的TextBlock样式设置以下ListBox的样式(特别是项目)。我什至不知道从哪里开始。这是ListBox:

<code>
    <ListBox Grid.Row="1" Grid.Column="0" 
      ItemsSource="{Binding Path=PowerOnList}" 
      Width="140" Height="160" 
      Foreground="Black" Background="White"
      HorizontalAlignment="Left"
      Name="PowerOnListBox" 
      SelectedIndex="{Binding PowerOnSelection}">
      <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
          <Setter Property="Focusable" Value="True"/>
          <Setter Property="FontSize" 
           Value="{Binding Source={StaticResource MediumFontSize}, 
                   Converter={StaticResource fontSizeConverter}}" />
          <Setter Property="Foreground" Value="Black"/>
        </Style>
      </ListBox.ItemContainerStyle>
    </ListBox>
</code>

这是主题中预定义的TextBlock样式:

<code>
    <Style x:Key="{ComponentResourceKey 
      TypeInTargetAssembly={x:Type themes:OurThemeResources}, 
      ResourceId=NormalTextBlockStyle}" 
      TargetType="TextBlock">
      <Setter Property="FontSize" 
        Value="{Binding Source={StaticResource DefaultFontSize}, 
        Converter={StaticResource fontSizeConverter}}" />
      <Setter Property="FontFamily" 
        Value="{StaticResource DefaultFont}" />
      <Setter Property="Foreground" 
         Value="{StaticResource NormalTextBrush}" />
    </Style>

</code>

帮助?

0 个答案:

没有答案
相关问题