Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to subclass control?
Message
From
24/04/2008 15:07:29
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01184867
Message ID:
01312961
Views:
16
>>And if you are worried about "all that [DefaultValue], Get{}, Set{} stuff." you may not like WPF. This is what a WPF get set looks like:
>>
>>
>>public static readonly DependencyProperty MyNameProperty =
>>  DependencyProperty.Register("MyName", typeof(string), typeof(MyClass),
>>                               new UIPropertyMetadata(MyClass.MyNameValueChanged));
>>
>>public string MyName{
>>   get { return (string)GetValue(MyNameProperty); }
>>   set { SetValue(MyNameProperty, value); }
>>
>>private static void MyNameValueChanged(DependencyObject d,
>>                                       DependencyPropertyChangedEventArgs e)
>>  {
>>  MyClass myClass = (MyClass)d;
>>  myClass.someObject.Text = (string)e.NewValue;
>>  }
>>
>
>Awww c'mon - not all properties have to be dependency properties. You're just trying to scare the lad away <g>

HeHe... true. But life is not going to be as simple in .NET as it was in VFP, and that was the point I was trying to make, and WPF adds even more complexity.

It's a trade off in my mind. What you loose in simplicity you gain in capabilities.

To be fair most of what he was trying to do with subclassing in WinForms would instead be done with styles. Simple stuff like overriding the font is pretty easy.

But today I wanted to fix the opacity of the icons on my menus, so that they looked disabled when the menuitem was disabled. I couldn't find a way in XAML of just targeting the icon in the menuitem, without overriding the template. So I overrode the template. I took code from the simple styles project and also used an object dumper to get some of what I needed. It's at 512 lines of XAML just to get that fix.

Again to be fair, I didn't have to write most of that XAML, and now have a menu template that I can tweak. I also got some other items fixed while I was in there, for instance my icons now display on a gradient background just like the menus in VS, which looks nice, And I can do things in that template you wouldn't even dream of trying in WinForms.

I love the power of WPF and I love what I can do with it, but simple is not a term I would use to describe it.

Well... not actually trying to scare him a way. Just want him to be prepared before he jumps in. Which I hope he does, we could use some more WPF programmers around here.<g>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform