Windows Presentation Foundation (WPF) Interview Questions and Answers

WPF Questions and Answers:

1 :: How can I use an application resource?

The following example shows an application definition file. The application definition file defines a resource section (a value for the Resources property). Resources defined at the application level can be accessed by all other pages that are part of the application. In this case, the resource is a declared style. Because a complete style that includes a control template can be lengthy, this example omits the control template that is defined within the ContentTemplate property setter of the style.

[XAML]
<Application.Resources>
<Style TargetType="Button" x:Key="GelButton" >
<Setter Property="Margin" Value="1,2,1,2"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Template">
<Setter.Value>

...

</Setter.Value>
</Setter>
</Style>
</Application.Resources>
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 0 No
Place Your Answer

2 :: How can I set an attached property in code?

The following example shows how you can set an attached property in code.

[C#]

DockPanel myDockPanel = new DockPanel();
CheckBox myCheckBox = new CheckBox();
myCheckBox.Content = "Hello";
myDockPanel.Children.Add(myCheckBox);
DockPanel.SetDock(myCheckBox, Dock.Top);
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 0 No
Place Your Answer

3 :: How can I mark the default value of a custom dependency property to be false?

Here is an example :

[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));
}
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 0 No
Place Your Answer

4 :: 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. A typical example for a read-only property is IsMouseHover

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)
);
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 0 No
Place Your Answer

5 :: How can I enumerate all the descendants of a visual object?

You can enumerate all the descendants of a visual object as follows :

[C#]

// Enumerate all the descendants of the visual object.
static public void EnumVisual(Visual myVisual)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
{
// Retrieve child visual at specified index value.
Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

// Do processing of the child visual object.

// Enumerate children of the child visual object.
EnumVisual(childVisual);
}
}
0/5 Rating (0 vote)
Is This Answer Correct?    0 Yes 0 No
Place Your Answer

Rate This Category:
0/5 Rating (0 vote)
Place Your Question



Top: Windows Presentation Foundation (WPF) Interview Questions and Answers
Windows Presentation Foundation (WPF) Interview Questions and Answers

Top Frequently Asked WPF Question
Frequently Asked WPF Job Interview Question


Top Frequently opened Applications Programs Job Interview categories
Most popular Applications Programs Job Interview categories

Comments About Windows Presentation Foundation (WPF) Interview Questions and Answers

Share your valuable opinions, ideas and suggestions about Windows Presentation Foundation (WPF) Interview Questions and Answers
While placing your comment your email address is required but won't be published any where else; Personal information will be kept confidential; we do not sell or release our respective visitors private information.
  1. Webmaster 23rd of May 2012

    Webmaster Said

    Tell us what you feel about Windows Presentation Foundation (WPF) Interview Questions and Answers
    All comments will be published after review. No login or registration is required to post a comment on Windows Presentation Foundation (WPF) Interview Questions and Answers We offer and invite you to submit your valuable comment now; Please be respectful of others when commenting. Insulting others, self-promotional comments, website promotional comments, marketing stuff, SEO Techniques, SMS-style content and off-topic comments will not be approved at this information portal.
    So start sharing your thoughts regarding Windows Presentation Foundation (WPF) Interview Questions and Answers
    Thank you.

Leave a Comment

Leave a Comment
  1.  Enter This Verification Code  Regenerate Verification Code  



Your reply will be added to the comment above (Below any other replies to this comment) -

Top Comments About: Windows Presentation Foundation (WPF) Interview Questions and Answers
Comments on Windows Presentation Foundation (WPF) Interview Questions and Answers

 
Top of Link batk to Windows Presentation Foundation (WPF) Interview Questions and Answers
Link batk to Windows Presentation Foundation (WPF) Interview Questions and Answers