none
mvvm 模式下怎么无法显示数据? RRS feed

  • 问题

  • mvvm模式下,怎么无法获取数据?不用mvvm下是可以获取数据的!请指教!

    Model: 

    public class MainPageModel
        {
            private DomainServiceGwsz _content;
            public IList<gs_dictitem> data

             {  get ;    set;}

              
            public MainPageModel()
            {
                _content = new DomainServiceGwsz();
             
                _content.Load(_content.GetAllQuery(),
                    o =>
                    {
                       
                        if (!o.HasError)
                        {

                            data = o.Entities as IList<gs_dictitem>;
                           
                        }
                    }
                   
                    , null);
              
     
            }

          
        }

    xaml:

    <UserControl
      x:Class="Gwsz.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
      xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
      xmlns:dataControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:GwszModel.Entities" xmlns:my1="clr-namespace:Gwsz.Web" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:my2="clr-namespace:Gwsz.Models" Loaded="UserControl_Loaded_1">
        <UserControl.Resources>
            <CollectionViewSource x:Key="mainPageModelViewSource" d:DesignSource="{d:DesignInstance my2:MainPageModel, CreateList=True}" />
            <CollectionViewSource x:Key="mainPageModeldataViewSource" Source="{Binding Path=data, Source={StaticResource mainPageModelViewSource}}" />
        </UserControl.Resources>
        <Grid Name="LayoutRoot"  Width="640" DataContext="{StaticResource mainPageModeldataViewSource}">
            <sdk:DataGrid AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="116,52,0,0" Name="dataDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="400">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn x:Name="descriptionColumn" Binding="{Binding Path=Description}" Header="Description" Width="SizeToHeader" />
                                   
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </Grid>
    </UserControl>

    2012年3月2日 9:44

答案