WEB开发网
开发学院WEB开发ASP.NET 稳扎稳打Silverlight(56) - 4.0通信之与 WCF Data... 阅读

稳扎稳打Silverlight(56) - 4.0通信之与 WCF Data Services 进行通信

 2010-10-12 12:29:56 来源:WEB开发网   
核心提示: 2、客户端Demo.xaml代码<navigation:Page x:Class="Silverlight40.WCFDataServices.Demo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/

2、客户端

Demo.xaml

代码

<navigation:Page x:Class="Silverlight40.WCFDataServices.Demo"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           Title="Demo Page">
    <Grid x:Name="LayoutRoot">
        <StackPanel Orientation="Vertical" HorizontalAlignment="Left">

            <!--
                    用于演示通过 WCF Data Services 实现数据的增删改查
                -->
            <StackPanel Orientation="Horizontal">
                <Button Name="btnGetData" Content="获取数据" Margin="5" Click="btnGetData_Click" />
            </StackPanel>

            <TextBlock Text="产品类别列表:" Margin="5" />
            <sdk:DataGrid Name="gridCategory" Margin="5" Height="200" Width="400" AutoGenerateColumns="False" ItemsSource="{Binding}"
                       SelectionChanged="gridCategory_SelectionChanged">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="类别ID" Binding="{Binding CategoryID}" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Header="类别名称" Binding="{Binding CategoryName}" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

            <TextBlock Text="产品列表:" Margin="5" />
            <sdk:DataGrid Name="gridProduct" Margin="5" Height="200" Width="400" AutoGenerateColumns="False" ItemsSource="{Binding}" >
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="产品ID" Binding="{Binding ProductID}" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Header="产品名称" Binding="{Binding ProductName}" />
                    <sdk:DataGridTextColumn Header="单价" Binding="{Binding UnitPrice}" IsReadOnly="True" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

            <Button Name="btnSave" Content="保存" Margin="5" Width="400" Click="btnSave_Click" />

 

            <!--
                    用于演示 WCF Data Services 的服务端分页
                -->
            <TextBlock Text="订单列表:" Margin="5,20,5,5" />
            <sdk:DataGrid Name="gridOrder" Margin="5" Height="200" Width="400" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding}" >
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="订单ID" Binding="{Binding OrderID}" />
                    <sdk:DataGridTextColumn Header="客户ID" Binding="{Binding CustomerID}" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
            <TextBlock Name="txtCurrentPageIndex" />
            <Button Name="btnPrev" Content="上一页" Margin="5" Width="400" />
            <Button Name="btnNext" Content="下一页" Margin="5" Width="400" />

        </StackPanel>
    </Grid>
</navigation:Page>

Tags:稳扎稳打 Silverlight 通信

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接