CSharpFeeds - All your C# feeds in one place.

Sponsors

Monday, January 18, 2010

Dependency property and value inheritance

by luisabreu via LA.NET [EN] on 1/18/2010 12:36:21 PM

In the previous post, I’ve talked a little bit about dependency properties and on how they’re defined. One of the advantages of using those properties is value inheritance. Take a look at the following snippet:

<UserControl x:Class="Tests.MainPage"
    xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" FontSize="30"> <StackPanel> <TextBlock FontSize="20">Hello there!</TextBlock> <ListBox> <ListBoxItem FontSize="12" Content=" Item 1" /> <ListBoxItem Content="Item 2" /> </ListBox> <Button Content="Say Hi!!!" /> <Button Content="Say Hi2!!!" FontSize="50" /> </StackPanel> </UserControl>

If you run the previous sample, you’ll notice that the elements that don’t override the FontSize dependency property end up inheriting the value of its parent’s property value. This is one of the advantages of using this kind of property in Silverlight and WPF. Do notice that unlike WPF, where you can opt in to value inheritance by passing FrameworkPropertyMetadataOptions.Inherits to the metadata info you use during the dependency property definition (register method call), in Silverlight there’s not way to influence this behavior.

And that’s it for now. Stay tuned for more about Silverlight.


email it!bookmark it!digg it!

Original Post: Dependency property and value inheritance

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us