简体   繁体   中英

Silverlight XAML databinding to a field

in the following code,

<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my:V_FinanceCalculatorDefaultValues, CreateList=true}" Height="0" LoadedData="v_FinanceCalculatorDefaultValuesDomainDataSource_LoadedData" Name="v_FinanceCalculatorDefaultValuesDomainDataSource" QueryName="GetV_FinanceCalculatorDefaultValuesQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my:DomainServiceFinanceCalculatorDefaultValues />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="modelId" Value="{Binding ElementName=modelIdTextBox, Path=Text}" />
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>

how do I set the value of the parameter to a field in the associated C# class?

public int SelectedModelUcConfigurator;

I tried something like this

 <riaControls:Parameter ParameterName="modelId" Value="{Binding ElementName=this, Path=SelectedModelUcConfigurator}" />

I realize this is something simple, but I'm new to WPF ... :-)

Thanks!

Try make a readonly property for SelectedModelUcConfigurator and bind to the property.

private int _selectedModelUcConfigurator; 

public int SelectedModelUcConfigurator
{ 
get { return _selectedModelUcConfigurator; } 
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM