WPF中组合框的DrawItem事件 [英] DrawItem event of combo box in WPF

查看:81
本文介绍了WPF中组合框的DrawItem事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以了解的地方...任何控件的事件...

我想在wpf中使用组合框的comboBox1_DrawItem事件...

它可以在普通的窗口应用程序中工作.....

请帮助我...

in WPF Where we can know ... Event of any Control...

i want to use comboBox1_DrawItem event of combo box in wpf...

it work in normal Window Application.....

Plse Help me...

推荐答案

WPF的方法非常不同.由于它的内容模型不同,因此不需要任何用于控件和控件项的自定义绘图事件.例如,您可以将其存储在组合框中的项目中……好吧,几乎所有东西.

在此处阅读有关WPF内容模型的信息: http://msdn.microsoft.com/en-us/library/bb613548 .aspx [^ ] .

WPF另一个不同级别的自定义工程图"是样式模板.阅读 http://msdn.microsoft.com/en-us/library/ms745683.aspx [ ^ ].

这是我可以为您设计的最简单的示例:

WPF approach is very different. It does not need any custom drawing events for controls and control items, because of its different content model. For example, you can store in the items of combo box… well, practically everything.

Read about WPF content model here: http://msdn.microsoft.com/en-us/library/bb613548.aspx[^].

Another different level of WPF "custom drawing" is styling and templating. Read http://msdn.microsoft.com/en-us/library/ms745683.aspx[^].

Here is the simplest example I could design for you:

<ComboBox>
   <ComboBoxItem>
      <TextBlock Background="Red">Red</TextBlock>  
   </ComboBoxItem>
   <ComboBoxItem>
      <TextBlock Background="Yellow">Yellow</TextBlock>
   </ComboBoxItem>
   <ComboBoxItem>
      <TextBlock Background="AliceBlue">Alice Blue</TextBlock>
   </ComboBoxItem>
</ComboBox>



这可能不是很有用,但可以使您有所了解.使用您的幻想和一些实验-您将能够定制绘图"几乎任何您想要的东西.请记住:图形应为矢量.您可以使用各种图形形状,渐变等.

—SA



This is perhaps not very useful but gives you some idea. Use your fantasy and some experimenting — you will be able to "custom-draw" nearly anything you want. Remember: the graphics should be vector. You can use all kinds of graphical shapes, gradients and more.

—SA


这篇关于WPF中组合框的DrawItem事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆