1

I have a ria DDS query whose parameter is bound to a dependency property of the code behind my silverlight page. The issue is that once the project dependency is changed I get the following error.

QueryParameters cannot be changed when CanLoad is false. Changing the QueryParameters initiates a load operation, and load operations are not permitted when CanLoad is false. Controls that invoke load operations should be disabled when CanLoad is false.

I'm at a loss on how to complete or cancel the load so I can change the details view for a project every time a new project is selected from a list.

<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:XT_PROJECTS, CreateList=true}" Height="0" LoadedData="ProjectDetailsDomainDataSource_LoadedData" Name="ProjectDetailsDomainDataSource" QueryName="getProjectDetails"  Width="0" >
        <riaControls:DomainDataSource.DomainContext>
            <my:MYservices />
        </riaControls:DomainDataSource.DomainContext>
        <riaControls:DomainDataSource.QueryParameters>
            <riaControls:Parameter ParameterName="project" Value="{Binding ElementName=ProjectDetailsPage, Path=project}" />
        </riaControls:DomainDataSource.QueryParameters>
    </riaControls:DomainDataSource>

public static readonly DependencyProperty projectIDDP =
    DependencyProperty.Register("project", typeof(string),typeof(ProjectDetails),
    new PropertyMetadata(""));
 public string projectID
    {
        get
        {
            return (string)GetValue(projectIDDP);
        }
        set
        {
            SetValue(projectIDDP, value);
        }
    }
4

2 回答 2

1

经过更多研究,我现在很确定您的上下文中必须有待处理的更改。在这种情况下,DomainDataSources “阻塞”,你不能给它们造成负载。

如果此错误发生在不同的情况下,我很想对此进行纠正。

如果您有待处理的更改,您的解决方案是

  1. 阻止用户输入(可能是负载的最终原因),例如通过禁用表单或
  2. 为提交和 DomainDataSource 使用不同的上下文(然后您将希望使用 RiaServicesContrib 在上下文之间复制实体)。
于 2013-02-05T14:47:17.040 回答
0

在更改参数之前添加提交是否有效?像这样

set
{ 
    if (xyzDomainDataSource.HasChanges)
        xyzDomainDataSource.SubmitChanges();
    SetValue(projectIDDP, value);        
}
于 2011-04-19T16:31:47.697 回答