Which XAML code fragment should you use?

You are creating a Windows Presentation Foundation application. You create the application by using Microsoft .NET Framework 3.5.
You create a window that has two tabs for the application. You associate the following XAML code fragment with the tab control that contains the two tabs.
<Window.Resources>
<c:PetSelection x:Key="myPetSelection" />
</Window.Resources>

You add a property named Index to the PetSelection class. You need to ensure that when the user clicks a tab, the SelectedIndex property value of the tab
control is transferred to the Index property of the myPetSelection object.
Which XAML code fragment should you use?

You are creating a Windows Presentation Foundation application. You create the application by using Microsoft .NET Framework 3.5.
You create a window that has two tabs for the application. You associate the following XAML code fragment with the tab control that contains the two tabs.
<Window.Resources>
<c:PetSelection x:Key="myPetSelection" />
</Window.Resources>

You add a property named Index to the PetSelection class. You need to ensure that when the user clicks a tab, the SelectedIndex property value of the tab
control is transferred to the Index property of the myPetSelection object.
Which XAML code fragment should you use?

A.
<TabControl SelectedIndex="{Binding Path=Index, Mode=OneWay, Source={StaticResource myPetSelection}}" IsSynchronizedWithCurrentItem="True">
<TabItem Header="Dogs">Dogs</TabItem>
<TabItem Header="Cats">Cats</TabItem>
</TabControl>

B.
<TabControl SelectedIndex="{Binding Path=Index, Mode=OneWayToSource, Source={StaticResource myPetSelection}}" IsSynchronizedWithCurrentItem="True">
<TabItem Header="Dogs">Dogs</TabItem>
<TabItem Header="Cats">Cats</TabItem>
</TabControl>

C.
<TabControl SelectedIndex="{Binding Path=Index, Mode=OneTime, Source={StaticResource myPetSelection}}" IsSynchronizedWithCurrentItem="True">
<TabItem Header="Dogs">Dogs</TabItem>
<TabItem Header="Cats">Cats</TabItem>
</TabControl>

D.
<TabControl SelectedIndex="{Binding Path=PetSelection, Mode=Default, Source={StaticResource myPetSelection}}" IsSynchronizedWithCurrentItem="True">
<TabItem Header="Dogs">Dogs</TabItem>
<TabItem Header="Cats">Cats</TabItem>
</TabControl>



Leave a Reply 0

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