:: Home

  login:         
  passwords:  

WPF FAQs

WPF General Questions
Concepts Element Tree
Concepts Dependency Property
Concepts Attached Property
Concepts Routed Events
Concepts Resources.
Concepts Animation
Concepts Freezable Object
Concepts Input and Commands.
Concepts Layouts
XAML Inline Styles and Templates
XAML XML Namespaces
XAML Code Behind
XAML Custom Class
XAML Type Converters
Content Model ItemControl
Content Model HeaderedItemsControl
Content Model HeaderedContentControl
Content Model Content Control
Content Model Decorator Content Model
Content Model Panel Content Model
Documents Serialization and Storage
Documents Annotations
Documents Flow Content
Documents Printing
Graphics and Multimedia Rendering Graphics
Graphics and Multimedia Animation and Timing
Graphics and Multimedia 2D Graphics
Graphics and Multimedia 3D Graphics
Graphics and Multimedia Visual Layer
Control Customization Adorners
Control Customization Stylable controls
Control Customization ControlTemplates
Data Data Binding
Data DragandDrop
Data Serialization
Globalization and Localization Attributes
Globalization and Localization Comments
Globalization and Localization Globalization Struc
Application and Deployment ClickOnce
Application and Deployment Frame
Application and Deployment Page
Application and Deployment Navigation
Application and Deployment Setup
Application and Deployment Window
Interoperability Message Loops Between
Interoperability Win32 in WPF
Interoperability WPF in Win32
Interoperability Windows Forms and WPF
Security Trusted Security
Security Partial Trust Security
Tools Microsoft Expression Blend
Tools ZAM3D
Tools XAMLPAD
Controls ToolTip
Controls TextBlock
Controls TabControl
Controls ProgressBar
Controls PrintDialog
Controls Popup
Controls TextBox
Controls Canvas
Controls ComboBox
Controls ListBox
Controls StatusBar
Controls ToolBar
Controls Context Menu
Controls Expander
Controls DocumentViewer
Controls FlowDocumentReader
Controls GroupBox
Controls GridSplitter
Controls Image
Controls Menu
Controls ScrollBar
Controls Slider
Controls RichTextBox
Controls Border
Controls Buttons

SilverLight Interview Qs

SAP Interview Questions

Oracle Interview Questions

PHP Interview Questions

Ajax Interview Questions

IIS 7.0

OOP Interview Questions

Ruby Interview Questions

Sql Server Interview Questions

Winforms Interview Questions

SharePoint 2007 Questions

Microsoft Crm Questions

Concepts Dependency Property Interview Questions & FAQs

Questions and answers for Concepts Dependency Property.
 

3. Concepts Dependency Property

    3.1 How can I create Custom Read-Only Dependency Properties ?
    3.2 How can I use Dependency Property MetaData?
    3.3 How can I register the default value of the State dependency property to be false?

3.1 How can I create Custom Read-Only Dependency Properties ?

The typical reason for specifying a read-only dependency property is that these are the properties that is used to determine the state, but where the state is defined in a multitude of factors. For example, the property IsMouseOver can be used when the user hovers over some element, attempting to change this value programmatically would cause inconsistency.

This example shows how to 'register' an attached property as read-only. You can use dependency properties on any 'DependencyObject' types.

[C#]



public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterReadOnly(

"IsBubbleSource",

typeof(Boolean),

typeof(AquariumObject),

new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)

);


3.2 How can I use Dependency Property MetaData?

Dependency property metadata exists as an object that can be queried to examine the characteristics of a dependency property. This metadata is also accessed frequently by the property system as it processes any given dependency property.

The metadata object for a dependency property can contain the following types of information.

  • Default value for the dependency property, if no other value can be determined for the dependency property by local value, style, inheritance, etc. For a thorough discussion of how default values participate in the precedence used by the property system when assigning values for dependency properties, see 'Dependency Property Value Precedence'.

  • References to callback implementations that affect coercion or change notification behaviors on a per-owner-type basis. Note that these callbacks are often defined with a non-public access level. So obtaining the actual references from metadata is generally not possible, unless the references are within your permitted access scope. For more information on dependency property callbacks, see 'Dependency Property Callbacks and Validation'.

  • If the dependency property in question is considered to be a WPF framework level property, the metadata might contain WPF framework level dependency property characteristics, which report information and state for services such as the WPF framework level layout engine and property inheritance logic.


3.3 How can I register the default value of the State dependency property to be false?s

You can do this with the following piece of code :

[C#]



public class MyStateControl : ButtonBase

{

public MyStateControl() : base() { }

public Boolean State

{

get { return (Boolean)this.GetValue(StateProperty); }

set { this.SetValue(StateProperty, value); }

}

public static readonly DependencyProperty StateProperty = DependencyProperty.Register(

"State", typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));

}

bottom user control
::  Home :: Services ::  Prices ::  Request Quote
Copyright 2007, Megasolutions Ltd