Test your knowledge

  1. You are writing a Silverlight 4 application. The application contains a class that has a Boolean property named ToShow. You wish to have a field that will only be shown to the user if the bound ToShow property returns true. Which code segment should you use?

    a. Only implement the Convert method with the following code snippet:

    if (value != null)
    {
    bool result = (Boolean)value;
    return result == true ? Visibility.Visible : Visibility.Collapsed;
    return result == true ? Visibility.Visible : Visibility.Collapsed;
    }
    return Visibility.Collapsed;
    

    b. Only implement the ConvertBack method with the following code snippet:

    if (value != null)
    {
    bool result = (Boolean)value;
    return result == true ? Visibility.Visible : Visibility.Collapsed;
    }
    return Visibility.Collapsed;
    

    c. Only implement the Convert method with the following code snippet:

    if (value != null)
    {
    bool result = (Boolean)value;
    return result;
    }
    return Visibility.Collapsed;
    

    d. Only implement the ConvertBack method with the following code snippet:

    if (value != null)
    {
    bool result = (Boolean)value;
    return result;
    }
    return Visibility.Collapsed;
    
  2. You are developing a Silverlight 4 based form. The form contains a TextBox control that is data bound to a property in a class that implements the INotifyPropertyChanged interface. When an invalid value is entered to the TextBox, the property throws an exception. You need to display the error message the property throws to the user. Which code segment should you use?

    a.<TextBox Text="{Binding ZipCode,Mode=TwoWay,ValidatesOnDataErrors=True}"/>

    b.<TextBox Text="{Binding ZipCode,Mode=OneWay,ValidatesOnDataErrors=True}"/>

    c.<TextBox Text="{Binding ZipCode,Mode=TwoWay,ValidatesOnExceptions=True}"/>

    d.<TextBox Text="{Binding ZipCode,Mode=TwoWay,NotifyOnValidationError=True}"/>

  3. You are developing a Silverlight 4 based application. The application contains a TextBlock control that is bound to a property called FirstName. The TextBlock control needs to display the string "Welcome back" before the value of FirstName. Which code segment should you use?

    a.<TextBlock Text="{Binding FirstName,StringFormat='Welcome back {FirstName}'}"/>

    b.<TextBlock Text="{Binding FirstName,StringFormat='Welcome back {0}'}"/>

    c.<TextBlock Text="Welcome back {Binding FirstName}"/>

    d.<TextBlock Text="{Binding FirstName,ConverterParameter='Welcome back {0}'}"/>

  4. You are developing a Silverlight 4 based application that contains a slider control. The slider is named Degrees and its values are between 1 and 360. You need to display the value of the control in a TextBlock control. Which code segment should you use?

    a.<TextBlock Text="{Binding Path=Value, ElementName=Degrees}"/>

    b.<TextBlock Text="{Binding Path=Value, Converter=Degrees}"/>

    c.<TextBlock DataContext="Degrees" Text="{Binding Path=Value}"/>

    d.<TextBlock Text="{Binding Path=Degree, ElementName=Degrees}"/>

  5. You are developing a Silverlight 4 application that contains a field that is bound to a property called TotalPrice. The field must be read-only, and it should not update the backend property. When a user updates other fields in the application, TotalPrice changes and needs to update the UI layer. Which binding mode should you use?

    a. TwoWay

    b. OneTime

    c. None

    c. OneWay

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.38.121