简体   繁体   English

像 C# 中的应用程序一样的控制面板

[英]Control Panel like application in C#

I would like to create some basic application that visually looks like Window's control panel:我想创建一些在视觉上看起来像 Window 控制面板的基本应用程序:

Control Panel in Windows 7 Windows 7 中的控制面板

  1. Large icons with titles below for each extra form.每个额外表格的下方带有标题的大图标。
  2. Double clicking the icon results opening some extra form.双击图标会打开一些额外的表格。
  3. You can navigate using keyboard arrows through the icons.您可以使用键盘箭头浏览图标。

The question is if there are some common way to do it?问题是是否有一些通用的方法来做到这一点? Well I think I can do it by adjusting style of application and adding the necessary behavior, but maybe there is some other way?好吧,我想我可以通过调整应用程序样式并添加必要的行为来做到这一点,但也许还有其他方法?

Moreover I remember that there was a way to create such things in Windows 95/98 by editing the folder's configuration file that had ".htm" extansion (if i'm not mistaken).此外,我记得有一种方法可以通过编辑具有“.htm”扩展名的文件夹配置文件(如果我没记错的话)在 Windows 95/98 中创建这样的东西。 I tried to google the method, but it looks like I use wrong keywords...我试图用谷歌搜索该方法,但看起来我使用了错误的关键字......

Using Spy++ I see that the Control Panel application uses a tree control and tree view but you probably do not need a hierarchical view.使用 Spy++ 我看到控制面板应用程序使用树控件和树视图,但您可能不需要分层视图。 Another possibility is what is called a list view (like the right side of Windows Explorer) but I am not sure what the equivalent in WPF is.另一种可能性是所谓的列表视图(如 Windows 资源管理器的右侧),但我不确定 WPF 中的等效项是什么。

If you mean something similar to this:如果您的意思与此类似:

在此处输入图片说明

You can bind an ObservableCollection of objects that represent a "page" to a ListBox, which you'd probably want to wrap in a UserControl.您可以将表示“页面”的对象的 ObservableCollection 绑定到 ListBox,您可能希望将其包装在 UserControl 中。 We'll call that UserControl PageSelector.我们将调用该 UserControl PageSelector。

If you wanted to include an address/search bar, you'd want to create additional UserControls, all of which you could wrap in another UserControl, which we'll call ControlPanel.如果您想包含一个地址/搜索栏,您需要创建额外的 UserControl,所有这些都可以包装在另一个 UserControl 中,我们将其称为 ControlPanel。

If you aren't already familiar with DependencyProperties and bindings, get to know them well.如果您还不熟悉 DependencyProperties 和绑定,请充分了解它们。 They make communicating between UserControls a breeze.它们使 UserControl 之间的通信变得轻而易举。

Further, you can create a UserControl called PageViewer, which would handle displaying the clicked page.此外,您可以创建一个名为 PageViewer 的 UserControl,它将处理显示单击的页面。 Then whenever a page in PageSelector is clicked, you can hide the PageSelector, show the PageViewer and set the DataContext of the PageViewer to the clicked page.然后,无论何时单击 PageSelector 中的页面,您都可以隐藏 PageSelector,显示 PageViewer 并将 PageViewer 的 DataContext 设置为单击的页面。 Note, the clicked page in PageSelector can be accessed by PageViewer using bindings.请注意,PageViewer 可以使用绑定访问 PageSelector 中单击的页面。

Hope this leads you somewhere!希望这能把你带到某个地方!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM