如何为 Metro 开发制作自定义控件和组件?
我想抢先一步,开始为 Metro (Win8) 制作一些自定义 C# 控件和组件,但我找不到任何有关如何开始的文档或博客文章,或者即使现在可以这样做。
Metro 控件只是 WPF 控件吗?我还不是 WPF 开发人员;创建自定义用户控件看起来很简单,但 Windows 8 开发人员预览版中不存在该项目类型。那么,WPF 自定义用户控件 (VS2010) 是我应该用于创建 Metro 控件的项目类型吗?除此之外,我找不到任何有关如何创建在 WPF/Metro 中使用的组件的文档;您可以创建一个吗?或者它只是一个不可见的自定义用户控件? (我希望有某种类型的组件容器,比如 winforms 使用的组件容器;Metro 的组件现在只是类库,并且不再包含设计器支持吗?)
I'd like to get ahead of the pack and start making some custom C# controls and components for Metro (Win8), but I can't find any documentation or blog posts on how to start, or even if it's possible right now.
Are metro controls just WPF controls? I'm not yet a WPF developer; creating a custom user control looks straightforward, but that project type doesn't exist in the Windows 8 developer preview. So, are WPF custom user controls (VS2010) the project type I should use for creating my Metro controls? Beyond that, I can't find any documentation on how to create a component for use in WPF/Metro; can you create one, or would it just be a custom user control that isn't visible? (I was hoping for some type of component container like the one winforms use; are components for Metro now only class libraries, and don't include designer support anymore?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在……非常困难。无法重写控件的 OnRender 等,即创建代码来呈现具有自定义外观的控件。但是,您可以创建自定义模板。您可以在模板中执行的任何操作都是合法的,这就是您处理自定义控件的方式。
另一种选择是直接使用光栅(位图)或矢量(Windows.UI.Xaml.Shape?)组件生成 UI,并像这样构建您的 UI。布莱赫。
Win8 Metro 很像 WPF,但它不是子集。相似但又非常不同。许多 WPF 控件没有过渡到 Win8 Metro;无法使用相同级别的渲染控制;并且某些系统功能(例如高级字体渲染)不存在。所有这一切可能会在即将发布的版本中发生变化,但目前看来微软正在试图限制开发人员创建自定义 UI 控件。
It's ... very difficult right now. There's no way to override OnRender or the like for a control, ie to create code to render a control with a custom appearance. However, you can create a custom template. Anything you can do in the template is legal, and that's how you have to approach custom controls.
One other option is to generate your UI using either raster (Bitmap) or vector (Windows.UI.Xaml.Shape?) components directly and build up your UI like that. Bleh.
Win8 Metro is a lot like WPF, but it isn't a subset. Similar but very different. Many WPF controls didn't make the transition to Win8 Metro; the same level of rendering control isn't available; and some system features (like advanced font rendering) aren't there. All this might change in coming releases, but right now it looks like Microsoft is trying to restrain developers from creating custom UI controls.