WEB开发网
开发学院图形图像Flash Silverlight 2 - Simple Editing of Web Service ... 阅读

Silverlight 2 - Simple Editing of Web Service Data in a DataGrid

 2008-10-24 11:46:57 来源:WEB开发网   
核心提示: At the point where the "Submit Changes..." button is pressed I just gather up which entries have been inserted, updated, deleted as arr

At the point where the "Submit Changes..." button is pressed I just gather up which entries have been inserted, updated, deleted as arrays and send them back over to the web service.

So...all in all, there's no rocket-science here at all. The XAML for my UI ends up looking like this;

<UserControl x:Class="SilverlightApplication14.Page"
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
  Width="400" Height="300">
  <Grid x:Name="LayoutRoot" Background="White">
  <Grid.RowDefinitions>
   <RowDefinition />
   <RowDefinition
    Height="48" />
   <RowDefinition
    Height="48" />
  </Grid.RowDefinitions>
  <Grid
   x:Name="gridLoading"
   Opacity="0.5"
   Visibility="Collapsed">
   <Rectangle
    Fill="Silver"
    RadiusX="10"
    RadiusY="10"/>
   <TextBlock
    FontSize="24"
    Text="Loading Grid..."
    HorizontalAlignment="Center"
    VerticalAlignment="Center" />
  </Grid>
  <d:DataGrid
   x:Name="theGrid"
   Margin="10">
   <d:DataGrid.Columns>
    <d:DataGridTextBoxColumn
     Header="Id"
     DisplayMemberBinding="{Binding Id}"
     IsReadOnly="True"/>
    <d:DataGridTextBoxColumn
     Header="First Name"
     DisplayMemberBinding="{Binding FirstName}" />
    <d:DataGridTextBoxColumn
     Header="Last Name"
     DisplayMemberBinding="{Binding LastName}" />
    <d:DataGridTextBoxColumn
     Header="Age"
     DisplayMemberBinding="{Binding Age}" />
   </d:DataGrid.Columns>
  </d:DataGrid>
  <Button
   Click="OnLoad"
   Grid.Row="1"
   Content="Load Data from Service"
   Margin="10" />
  <Button
   Click="OnSave"
   Grid.Row="2"
   Content="Submit Changes to Service"
   Margin="10"/>
 </Grid>
</UserControl>

and the code behind the UI ends up looking like this ( pretty rough and ready stuff this );

上一页  1 2 3 4  下一页

Tags:Silverlight Simple Editing

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