Binding AutoCompleteBox inside DataTemplate
I have the following AutoCompleteBox defined inside a DataTemplate:
<Window.Resources>
<DataTemplate x:key="PaneTitleTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinition>
<ContentPresenter Content="{Binding}" />
<toolkit:AutoCompleteBox x:Name="InsertBox" ItemsSource="{???}" />
</Grid>
</DataTemplate>
</Window.Resources>
...
<radRock:RadPane x:Name="pane1" TitleTemplate="{StaticResource PaneTitleTemplate}"/>
Now I would like to fill it with a list of strings, but I don't know which binding to use. The string list is an instance variable from the window. What should I do?
+2
a source to share
1 answer
Part of the question is your DataContext. If it is the window itself or if it is some other object. If it is a window, you do not need to specify it in the binding, if it is some other object, then you must specify that you are using the window as the binding source. I think you want to use binging (you can remove ElementName if Window is DataContext):
ItemsSource="{Binding StringListName, ElementName=WindowName}"
Obviously, replace StringListName and WindowName with the name they actually have in your window.
+1
a source to share