0

我有一个 silverlight 自动完成框,在 codebehind.cs 添加 ItemsSource ,还设置了 valuemember 路径,它不显示任何数据。

这是代码,

<sdk:AutoCompleteBox   Margin="105,2,40,0" ItemsSource="{Binding}" ValueMemberPath="Code" FilterMode="Contains" IsTextCompletionEnabled="True" x:Name="txtcode"  Height="23" VerticalAlignment="Top" TabIndex="1" TabNavigation="Local" >
                            <sdk:AutoCompleteBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock  />
                                </DataTemplate>
                            </sdk:AutoCompleteBox.ItemTemplate>
                        </sdk:AutoCompleteBox>

txtcode.ItemsSource = collection;
4

2 回答 2

0

可能您在 DataTemplate 中错过了这个,

<TextBlock Text="{Binding Code}" />
于 2013-09-30T18:23:42.467 回答
0

你应该先绑定那个文本框

示例代码:

  <sdk:AutoCompleteBox   Margin="105,2,40,0" ItemsSource="{Binding}" ValueMemberPath="Code" FilterMode="Contains" IsTextCompletionEnabled="True" x:Name="txtcode"  Height="23" VerticalAlignment="Top" TabIndex="1" TabNavigation="Local" >
                                <sdk:AutoCompleteBox.ItemTemplate>
                                    <DataTemplate>
                                       <TextBlock Text="{Binding Item}" />
                                    </DataTemplate>
                                </sdk:AutoCompleteBox.ItemTemplate>
                            </sdk:AutoCompleteBox>

    txtcode.ItemsSource = collection;
于 2013-10-01T09:08:25.277 回答