WPF - 创建自定义 ItemsControl

发布于 2024-07-15 19:16:56 字数 234 浏览 11 评论 0原文

我正在考虑为 WPF 创建自定义控件,并且发现了一些相当有用的博客,其中模糊地介绍了足够的细节,但我仍然有点挣扎。

基本上,我想要创建的东西类似于臭名昭著的“Coda Slider”,但我只是不知道如何正确开始。 任何人都可以向我指出某人/某处的方向,让我了解创建自定义 ItemControl 的内情,或者向我提供基本信息,例如我需要覆盖哪些 ItemsControl 成员?

所有的帮助都会得到慷慨的接受。

I'm looking into creating custom controls for WPF and I've found some reasonably useful blogs and such that vaguely go into enough detail but I'm still struggling a bit.

Basically, what I'm trying to create is something akin to the infamous 'Coda Slider' but i just don't know enough to get started properly. Can anyone either point me in the direction of someone/somewhere to give me the low-down on creating custom ItemControls or provide me with the basic information like what ItemsControl members i need to override?

All help would be graciously received.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不醒的梦 2024-07-22 19:16:56

我在一个名为“WittyTwitter”的开源 WPF 项目中看到了相同的功能。 当我查看代码时,他们使用的是 Kevin Moore 的“WPF Bag-o-Tricks”库中名为 ZapScroller 的东西。 他是 Microsoft 的 WPF 项目经理。 看看这里:

http://work.j832 .com/2008/03/bag-o-tricks-march-edition.html

I had seen this same functionality in an open source WPF project called "WittyTwitter". When I looked through the code, they were using something called the ZapScroller in Kevin Moore's "WPF Bag-o-Tricks" library. He was a PM for WPF at Microsoft. Have a look here:

http://work.j832.com/2008/03/bag-o-tricks-march-edition.html

ㄖ落Θ余辉 2024-07-22 19:16:56

构建自定义 WPF 控件只不过是编写一个类并从 WPF 中提供的基类继承该类。

如何创建自定义 WPF 控件

Building a custom WPF control is nothing more than writing a class and inheriting the class from a base class that is provided in WPF.

How to Create a Custom WPF Control

北音执念 2024-07-22 19:16:56

我认为您必须问自己的第一个问题是为什么您觉得需要自定义控件? 您是否正在暴露新行为? 如果没有,那么样式和模板是您需要关注的地方。

如果您确实计划添加一些新功能,例如公开新属性或创建一些真正不同的东西,那么我确信 Google 搜索一下就能找到您需要的内容。 例如,这是 Sacha Barber 的一篇出色的文章,他在其中展示了继承自现有的控制。

我并不是想翻转:也许你可以更具体地说明你遇到的问题或疑问。

I think the first question you have to ask yourself is why you feel you need a custom control? Are you exposing new behavior? If not, then Styling and Templating are where you need to focus.

If you really plan to add some new feature, like exposing a new property or creating something really different, then I'm sure a little Google searching will find what you need. For example, here is an excellent article by Sacha Barber where he shows inheriting from an existing control.

I'm not trying to be flip: perhaps you could be more specific about the problems or questions you are having.

倚栏听风 2024-07-22 19:16:56

如果我错了,请纠正我,但只要看看“尾声滑块”,它看起来基本上是一个带有动画的 TabControl。

我非常确定,通过使用动画和/或附加属性来使用 TabControl 的自定义模板,您会得到更好的服务。

如果是这样,请告诉我们,我们一定能为您指明正确的方向。 WPF 很少需要自定义控件。

Correct me if I'm wrong, but just looking at the "coda slider", it looks to basically be a TabControl with animations.

I'm pretty sure you would be better served by using a custom templating of the TabControl using animations and/or attached properties.

If that is the case, tell us and we can certainly point you in the right direction. Custom controls are rarely a necessity with WPF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文