开发者

Silverlight childwindow combobox lookup

开发者 https://www.devze.com 2023-03-16 14:06 出处:网络
I am trying my hardest with silverlight but keep getting caught at hurdles for simple tasks.I have a main datagrid on my main form that lists addresses.I then have a child window that allows a user to

I am trying my hardest with silverlight but keep getting caught at hurdles for simple tasks. I have a main datagrid on my main form that lists addresses. I then have a child window that allows a user to edit these addresses with a combobox that does a country look up. I have an AdreessDomainDataSource and a CountryDo开发者_如何学PythonmainDataSource. I have my combo box in my child window with code as follows:

         <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">

This writes back correctly when i change to a different item in the list but on start up it is always replaced to the first item in the CountryDomainDataSource list. I have put a breakpoint on my web.g.vb code and it appears that intCountryID is set correctly on start up but straight after returning it, it is getting overwritten by the first value in the list. I have not written any code to set this value to the first value in my CountryDomainDataSource list? It appears that after the CountryDomainDataSource_LoadedData event is finished then it sets the countryid there. Is there anyway to make my CountryDomainDatasource load first and then my AddressDomainDatasource second or am i doing something silly or wrong here as i have been scratching my head over this for awhile?

Any help would be much appreciated.

Thanks


When a DDS loads data successfully, it will select the first item in the list. For this reason (among others), I recommend you don't use it to populate ComboBoxes. Here are a couple posts put together by Jeff and me explaining the reasoning and better alternatives.

  • ComboBox Sample for RIA Services
  • DomainDataSource, ComboBox, and Load Blocking
  • ComboBox FAQ


Set AutoLoad="False" on AddressDomainDatasource to stop it auto-loading and trigger the Load() of AddressDomainDatasource from the CountryDomainDataSource_LoadedData event.

Or you could just set the LoadDelay of AddressDomainDatasource (might be a simpler option).

0

精彩评论

暂无评论...
验证码 换一张
取 消