WPF IsReadOnly property problem

Infographics by vecteezy.com


Hmm... I don't know how many peoples have met with similar problem to my, but I think this what I found is really strange. The problem is with binding something to IsReadOnly property, for example in TextBox control. I created some template which is using this property as a trigger source, so when control is ReadOnly its look is different.

When I was trying to create trigger in Expression Blend 4, the property disappears like on picture below.



Great! Don't You think :p
I want to show here some solution for this problem. Here is my template:



But it is not the point. Look on line 59 on previous listing - one important line. There I defined trigger invoked when my attached property will change: core:Attach.IsReadOnly. So now I can use this like below in XAML code.


I'm using here Binding to ReadMode property from DataContext. Below definition of this attached property.


I hope this will help someone.

Oh, and one think, I created this on Windows 7, so in Template I'm using PresentationFramework.Aero reference, if You are using other version You must create the template by Yourself and then add my Trigger definition in XAML.

I'm pretty sure you see that this is just simple example of using Attached properties :-)

Comments

  1. Unable to download the zip file. Please upload it again.

    ReplyDelete
  2. Yes, sorry for that, I'm working on moving my blog to custom server and locate there all files. For now I'm not able to put files here. Sorry for that. Thanks for visiting my blog!

    ReplyDelete

Post a Comment