p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Windows Phone 7 Application Development: Building Windows Phone Applications Using S (http://p2p.wrox.com/forumdisplay.php?f=634)
-   -   No data is shown after Binding (http://p2p.wrox.com/showthread.php?t=87791)

bmw June 20th, 2012 01:29 PM

No data is shown after Binding
 
I followed the book to set up the data binding in Blend in Chapter 12. However, the data didn't shown in the textbook. Would you point me what I missed. Thansk in advance.

The following is my MaingPage.xaml.


Code:

<phone:PhoneApplicationPage
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
        x:Class="test.MainPage"
        SupportedOrientations="Portrait" Orientation="Portrait"
        shell:SystemTray.IsVisible="True">

        <phone:PhoneApplicationPage.FontFamily>
                <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
        </phone:PhoneApplicationPage.FontFamily>
        <phone:PhoneApplicationPage.FontSize>
                <StaticResource ResourceKey="PhoneFontSizeNormal"/>
        </phone:PhoneApplicationPage.FontSize>
        <phone:PhoneApplicationPage.Foreground>
                <StaticResource ResourceKey="PhoneForegroundBrush"/>
        </phone:PhoneApplicationPage.Foreground>

        <Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{d:DesignData /SampleData/OrderSampleData.xaml}">
                <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!--TitlePanel contains the name of the application and page title-->
                <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
                        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
                </StackPanel>

                <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                        <TextBox Height="48" Margin="68,71,204,0" TextWrapping="Wrap" Text="ox" VerticalAlignment="Top"
                                x:Name="txtBinding" DataContext="{Binding Address, Mode=TwoWay}" Foreground="#FF6EE275" Background="#BFE48888"/>
                </Grid>
        </Grid>
</phone:PhoneApplicationPage>

There are my code behind on MainPage.xaml:
Code:

namespace test
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
                       
                        DataContext = new Order()
            {
                Address = "My house",
                Total = 500,
                Products = new ObservableCollection<Product>
                                {
                                        new Product
                                        {
                                                Name="Gizmos",
                                                Price=200,
                                                Description="something something something",
                                                IsSelected=true
                                        },
        }
                        };
                }
    }
}



All times are GMT -4. The time now is 12:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.