Which XAML code fragment should you use?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application processes hospital medical records. The application contains a class named Patient that has a property named Age. You enter information about the patient in a window named Medical Form. In the window, you enter the age of the patient in a textbox named txtAge. You need to ensure that the application meets the following requirements:
* It updates the Age property automatically when you enter the age of the patient in the txtAge textbox.
* It updates the txtAge textbox automatically when you change the Age property of the Patient class.
Which XAML code fragment should you use?

You are creating a Windows Presentation Foundation application by using Microsoft .NET Framework 3.5.
The application processes hospital medical records. The application contains a class named Patient that has a property named Age. You enter information about the patient in a window named Medical Form. In the window, you enter the age of the patient in a textbox named txtAge. You need to ensure that the application meets the following requirements:
* It updates the Age property automatically when you enter the age of the patient in the txtAge textbox.
* It updates the txtAge textbox automatically when you change the Age property of the Patient class.
Which XAML code fragment should you use?

A.
<TextBox Name="txtAge">
<TextBox.Resources>
<src:Patient x:Key="AgeResource" />
</TextBox.Resources>
<TextBox.Text>
<Binding Source = "{StaticResource AgeResource}" Mode="OneWayToSource" Path="Age" />
</TextBox.Text>
</TextBox>

B.
<TextBox Name="txtAge">
<TextBox.Resources>
<src:Patient x:Key="AgeResource" />
</TextBox.Resources>
<TextBox.Text>
<Binding Source = "{StaticResource AgeResource}" Mode="OneWay" Path="Age" />
</TextBox.Text>
</TextBox>

C.
<TextBox Name="txtAge">
<TextBox.Resources>
<src:Patient x:Key="AgeResource" />
</TextBox.Resources>
<TextBox.Text>
<Binding Source = "{StaticResource AgeResource}" Mode="Default" Path="Age" />
</TextBox.Text>
</TextBox>

D.
<TextBox Name="txtAge">
<TextBox.Resources>
<src:Patient x:Key="AgeResource" />
</TextBox.Resources>
<TextBox.Text>
<Binding Source = "{StaticResource AgeResource}" Mode="OneTime" Path="Age" />
</TextBox.Text>
</TextBox>



Leave a Reply 0

Your email address will not be published. Required fields are marked *