Attached Property verboseness

I'm trying to understand what all is going on when I create an attached property.

Are the SetText() and GetText() methods (that are inserted via the snippet/template and that I see in many examples) required? What within the framework is using them?

public static readonly DependencyProperty TextProperty =
                                        new PropertyMetadata(default(string)));

public static void SetText(UIElement element, string value)
    element.SetValue(TextProperty, value);

public static string GetText(UIElement element)
    return (string)element.GetValue(TextProperty);

Could I replace those methods with a simple property, so that I can get/set through a property instead of using those methods?

public string Text
    get { return (string)GetValue(TextProperty); }
    set { SetValue(TextProperty, value); }


They are just for your convenience, the framework does not use them.

You cannot do the latter as you need to somehow pass the instance on which the property is set, as the property is attached you do not have the instance as this.

Need Your Help

Split screen proportionally LWUIT

java-me lwuit lwuit-textarea lwuit-layouts

I want to split the screen by 30% and 70% vertically, How can i achieve this with lwuit? I used/tried GridLayout but it splits the screen equally. Need a example code for this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.