首页 > 解决方案 > 如何在 Windows 10 上为 WPF 应用程序的工具栏查找默认图标?

问题描述

Microsoft 文档的Editing Commands部分在顶部显示了一个工具栏,上面带有. 但是文档没有描述这些图标在系统上的位置。当我将它们复制到我的项目中时,它会给出如下所示的错误。问题:我怎样才能找到我的那些图标(如下图所示)?WPFRichTextBoxBullets, Numbering, Indents etcXAMLWindows 10

错误[我的项目中 XAML 页面的屏幕截图。单击图像以获得更好的视图]:

在此处输入图像描述

来自Microsoft 示例的图像:

在此处输入图像描述

标签: wpfwindows-10wpf-controlswpftoolkit

解决方案


图像补丁应使用斜杠 (/) 而不是反斜杠 ()。图像应位于项目根目录下的图像文件夹中。

在此处输入图像描述

<Window x:Class="RichTextBoxInputPanelDemo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="400" Width="600"
>
  <Grid>

    <!-- Set the styles for the tool bar. -->
    <Grid.Resources>
      <Style TargetType="{x:Type Button}" x:Key="formatTextStyle">
        <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
        <Setter Property="Width" Value="30"></Setter>
        <Setter Property="FontSize" Value ="14"></Setter>
        <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>
      </Style>

      <Style TargetType="{x:Type Button}" x:Key="formatImageStyle">
        <Setter Property="Width" Value="30"></Setter>
        <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>
      </Style>
    </Grid.Resources>

    <DockPanel Name="mainPanel">

      <!-- This tool bar contains all the editing buttons. -->
      <ToolBar Name="mainToolBar" Height="30" DockPanel.Dock="Top">

        <Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Cut" ToolTip="Cut">
          <Image Source="Images/EditCut.png"></Image>
        </Button>


      </ToolBar>

      <!-- By default pressing tab moves focus to the next control. Setting AcceptsTab to true allows the 
           RichTextBox to accept tab characters. -->
      <RichTextBox Name="mainRTB" AcceptsTab="True"></RichTextBox>
    </DockPanel>
  </Grid>
</Window>

推荐阅读