Creating Custom Control in WPF (.Net 3.5)
-
Dear Friends. I want to make a custom control for wpf that a custom combobox. I need to change combobox item drawing. how can I change it from code or access to XAML code of combobox in custom control project. (I'm using this code for inherit combobox:
Public Class CustomControl1
Inherits ComboBox)
Regards. Mehdi Ghiasi
-
Dear Friends. I want to make a custom control for wpf that a custom combobox. I need to change combobox item drawing. how can I change it from code or access to XAML code of combobox in custom control project. (I'm using this code for inherit combobox:
Public Class CustomControl1
Inherits ComboBox)
Regards. Mehdi Ghiasi
Generally if you think that you want to change the appearance/behaviour of a control in XAML by creating a subclass, this means that you're approaching the problem in the wrong way. As the standard WPF controls are "lookless", this means that you can change the template to suit your own purposes. The only time that you should even consider inheriting is if you want to radically alter the behaviour of the underlying control - in other cases, you could consider implementing the functionality with Attached Properties/Attached Behaviours.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Generally if you think that you want to change the appearance/behaviour of a control in XAML by creating a subclass, this means that you're approaching the problem in the wrong way. As the standard WPF controls are "lookless", this means that you can change the template to suit your own purposes. The only time that you should even consider inheriting is if you want to radically alter the behaviour of the underlying control - in other cases, you could consider implementing the functionality with Attached Properties/Attached Behaviours.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
So, How can I make a Color Picker Combo Box (Color Picker Drop Down list) for my WPF Application? (I can make it in my program with both XAML and code. but in a class, I haven't XAML, how can I Change ItemTemplate of ComboBox? I've made this control for windows forms with
DrawItem
Event.)Regards. Mehdi Ghiasi