O'Reilly logo

XAML Developer Reference by Ashish Ghoda, Mamta Dalal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Templating, Conversion, and Validation

Consider a simple example of a ListBox bound to the CompanyName column of a table named Customers. The following is the XAML markup for the example:

<Grid Height="383" Width="508">
    <ListBox Height="155" HorizontalAlignment="Left" Margin="12,29,0,0"
     Name="listBox1" VerticalAlignment="Top" Width="202" ItemsSource="{Binding}">
    </ListBox>
    <TextBlock Height="22" HorizontalAlignment="Left" Margin="12,0,0,0"
    Name="textBlock1" Text="Company Name" VerticalAlignment="Top" Width="146" />
</Grid>

The code-behind class logic is as follows:

using System; . . . using Silverlight_and_Data.NorthwindServiceReference; namespace Silverlight_and_Data { public partial class MainPage : Page { public MainPage() { InitializeComponent(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required