我正在尝试使用silverlight最困难的事情,但是在简单任务中不断遇到障碍。我在我的主窗体上列出了一个主要的数据网格,它列出了地址。然后我有一个子窗口,允许用户用一个国家查找的组合框编辑这些地址。我有一个AdreessDomainDataSource和一个CountryDomainDataSource。 我有我的组合框在我的子窗口,代码如下:Silverlight子窗口组合框查找
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Country, CreateList=true}" Height="0" Name="CountryDomainDataSource" QueryName="GetCountriesQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:CountriesContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:Address, CreateList=true}" Height="0" Name="AddressDomainDataSource" QueryName="GetAddressQuery" Width="0" LoadDelay="10000">
<riaControls:DomainDataSource.DomainContext>
<my:AddressContext />
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.QueryParameters>
<riaControls:Parameter ParameterName="intAddressID" />
</riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>
<Grid DataContext="{Binding ElementName=AddressDomainDataSource, Path=Data}" HorizontalAlignment="Left" Margin="63,27,0,0" Name="Grid1" VerticalAlignment="Top">
这当我更改为不同的项目在列表中,但在启动时它总是代替在第一项写回正确CountryDomainDataSource列表。我在我的web.g.vb代码上放了一个断点,看起来intCountryID在启动时设置正确,但在返回后直接进行设置,它将被列表中的第一个值覆盖。我没有写任何代码将此值设置为CountryDomainDataSource列表中的第一个值?看起来,CountryDomainDataSource_LoadedData事件完成后,它会在那里设置countryid。是否有无论如何使我的CountryDomainDatasource加载第一,然后我的AddressDomainDatasource第二,或者我在这里做一些愚蠢或错误,因为我一直在挠我的头一段时间?
任何帮助将不胜感激。
感谢
我遵循你的建议,并使用你的ComboBoxExtension,虽然我似乎遇到了可能我的Domaincontexts和Async和AsyncEager模式的一些问题。如果我在AsyncEager中运行,我只是得到单个ID查找值。如果我在Async中运行,我什么也得不到。所以我不知道它是否与共享DomainContexts。我将子窗口上的网格的DataContext设置为等于打开时父窗口datagrid中当前选择的实体项目。 – Oly
然后,我在Childwindow.Resources中声明CountryContext Lookup,然后在组合框的上方添加ComboBoxDataSource。现在您提到了共享DomainContext。我将如何去做这件事?我有点困惑。再次感谢 – Oly
在运行这个程序时,我在代码上放了一个断点,它似乎没有在我的DomainService中调用我的OperationName。这应该在表单启动时运行吗?谢谢,Oly – Oly