I want to have an autocomplete text box (or possibly a combo box) in the edit template of a RadGridView. I think I know how to do this, however, I need to bind this control to an observable collection that is created when the application is started, and held as an application variable:-
I.e:-
This is populated from a ria services call, but as it's an unchanging reference list, it's a lot more efficient to store this in memory, than make calls to the database thousands of times a day.
Outside of the RadGrid, the autocomplete box works fine:-
The itemssource is set by the code:-
However, I'm stuck on how to get this binding to work when the control is part of a CellEditTemplate in a RadGrid.
Can I still bind in code behind, or do I need to do it in XAML. Either way, I'm at a loss at how to do this.
I.e:-
public
partial
class
App : Application
{
public
ObservableCollection<DiagnosisReference> DiagnosisLookups =
new
ObservableCollection<DiagnosisReference>();
}
This is populated from a ria services call, but as it's an unchanging reference list, it's a lot more efficient to store this in memory, than make calls to the database thousands of times a day.
Outside of the RadGrid, the autocomplete box works fine:-
<
sdk:AutoCompleteBox
x:Name
=
"DiagComplete"
Width
=
"70"
FilterMode
=
"Custom"
Margin
=
"5,0,0,0"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
TabIndex
=
"0"
>
<
sdk:AutoCompleteBox.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding DiagnosisCode}"
Margin
=
"0,0,5,0"
/>
<
TextBlock
Text
=
"{Binding Description}"
FontSize
=
"7"
FontStyle
=
"Italic"
Foreground
=
"Gray"
/>
</
StackPanel
>
</
DataTemplate
>
</
sdk:AutoCompleteBox.ItemTemplate
>
</
sdk:AutoCompleteBox
>
The itemssource is set by the code:-
DiagComplete.ItemsSource = curApp.DiagnosisLookups;
However, I'm stuck on how to get this binding to work when the control is part of a CellEditTemplate in a RadGrid.
Can I still bind in code behind, or do I need to do it in XAML. Either way, I'm at a loss at how to do this.