Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WPF内置命令_.net_Wpf_Command - Fatal编程技术网

.net WPF内置命令

.net WPF内置命令,.net,wpf,command,.net,Wpf,Command,我正在寻找内置WPF命令的完整列表 到目前为止,我找到的最好的列表是,但它没有列出所有命令 一些很好的细节是: 支持命令的控件/组件(例如,支持编辑命令,如粘贴、复制、剪切、重做和撤消) 默认键手势和UI文本(可从中提取) 查看课程和课程。这些类都包含表示各种标准路由命令的静态属性,您可以在自己的应用程序中使用这些命令,并与框架内的内部控件交互。签出此链接 WPF的内置命令作为五个不同类的静态属性公开: * ApplicationCommands—Close, Copy, Cut, D

我正在寻找内置WPF命令的完整列表

到目前为止,我找到的最好的列表是,但它没有列出所有命令

一些很好的细节是:

  • 支持命令的控件/组件(例如,支持编辑命令,如粘贴、复制、剪切、重做和撤消)

  • 默认键手势和UI文本(可从中提取)

查看课程和课程。这些类都包含表示各种标准路由命令的静态属性,您可以在自己的应用程序中使用这些命令,并与框架内的内部控件交互。

签出此链接

WPF的内置命令作为五个不同类的静态属性公开:

    * ApplicationCommands—Close, Copy, Cut, Delete, Find, Help, New, Open, Paste, Print, PrintPreview, Properties, Redo, Replace, Save, SaveAs, SelectAll, Stop, Undo, and more 

    * ComponentCommands—MoveDown, MoveLeft, MoveRight, MoveUp, ScrollByLine, ScrollPageDown, ScrollPageLeft, ScrollPageRight, ScrollPageUp, SelectToEnd, SelectToHome, SelectToPageDown, SelectToPageUp, and more 

    * MediaCommands—ChannelDown, ChannelUp, DecreaseVolume, FastForward, IncreaseVolume, MuteVolume, NextTrack, Pause, Play, PreviousTrack, Record, Rewind, Select, Stop, and more 

    * NavigationCommands—BrowseBack, BrowseForward, BrowseHome, BrowseStop, Favorites, FirstPage, GoToPage, LastPage, NextPage, PreviousPage, Refresh, Search, Zoom, and more 

    * EditingCommands—AlignCenter, AlignJustify, AlignLeft, AlignRight, CorrectSpellingError, DecreaseFontSize, DecreaseIndentation, EnterLineBreak, EnterParagraphBreak, IgnoreSpellingError, IncreaseFontSize, IncreaseIndentation, MoveDownByLine, MoveDownByPage, MoveDownByParagraph, MoveLeftByCharacter, MoveLeftByWord, MoveRightByCharacter, MoveRightByWord, and more

很容易显示所有加载程序集中所有命令的完整列表:

  public string[] GetAllCommands()
  {
    return (
      from assembly in AppDomain.CurrentDomain.GetAssemblies()
      from type in assembly.GetTypes()
      from prop in type.GetProperties()
      where
        typeof(ICommand).IsAssignableFrom(prop.PropertyType) &&
        prop.GetAccessors()[0].IsStatic
      orderby type.Name, prop.Name
      select type.Name + "." + prop.Name
    ).ToArray();
  }
加载PresentationFramework后,我得到了答案底部的列表,您将看到它是绝对完整的

如果您还想查看命令类型(例如routeduicommand)和手势,可以将其添加到LINQ:

      let commandType = prop.PropertyType

      let gestures =
        typeof(UIElement).IsAssignableFrom(commandType) ?
          ((UIElement)prop.GetValue(null)).InputGestures :
        null
那么您的选择可能如下所示:

      select type.Name + "." + prop.Name + " " + commandType.Name + " " + gestures
static string ConvertILToString(byte[] bytes)
{
  return new string(bytes.Where(b => b!=0).Select(b => (char)b).ToArray());
}
以编程方式找出哪些控件使用给定命令执行某些操作也是可能的。基本上,类似这样的东西应该会起作用(没有尝试过,但这会给你一个想法):

其中ConvertILToString可能是这样的:

      select type.Name + "." + prop.Name + " " + commandType.Name + " " + gestures
static string ConvertILToString(byte[] bytes)
{
  return new string(bytes.Where(b => b!=0).Select(b => (char)b).ToArray());
}
结果可以任意使用,例如,可以使用ItemsControl显示:

<ItemsControl Source="{Binding classesReferencingCommand}">
  <ItemsControl.ItemTemplate>
    <DataTemplate>
      <StackPanel>
        <TextBox Text="{Binding typeName}" FontWeight="Bold">
        <ItemsControl Source="{Binding referencedCommands}" Margin="10 0 0 0">
          <ItemsControl.ItemTemplate>
            <DataTemplate>
                <TextBox Text="{Binding displayAs}" />
      ... close all tags ...
这张单子是完整的


如果主题中有任何其他手势,可以通过加载主题资源字典并对其执行LINQ来轻松提取这些手势。查询很简单:只需搜索
更新:我认为主题中没有任何手势,因为默认手势是从参考资料中加载的。所以这部分可能没有必要。

我已经看过了,但是我要查找的信息太分散了。我正在寻找一个包含所有命令的紧凑列表,以及一些相关注释。我知道,您正在尝试构建更多的命令概要。如果我有时间,我会编辑。微软应该在MSDN文档中有一个WPF控件的标准部分,称为“支持的命令”或类似的内容。这就是我要说的。起初,我认为MSDN已经有了这样的文档。这就是为什么我把这个问题标记为社区维基。这和我在这个问题上的链接是一样的。谢谢你的回复。伙计,我认为这是目前为止最好的答案。这个周末我将尝试classesReferencingCommand查询。有一段时间,我会保留这个问题,看看是否还有其他问题,但我想你会得到公认的答案。非常感谢。