专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Silverlight

AutoCompleteBox 异步调用WCF 为什么结果不显示?该怎么处理

发布时间:2011-06-27 20:17:12 文章来源:www.iduyao.cn 采编人员:星星草
AutoCompleteBox 异步调用WCF 为什么结果不显示?
<input:AutoCompleteBox x:Name="AutoBox" Height="22" Margin="91,6,0,0" VerticalAlignment="Top" Width="180" RenderTransformOrigin="0.5,1" MinimumPrefixLength="0" MaxDropDownHeight="0" Populating="AutoBox_Populating" HorizontalAlignment="Left">
  <input:AutoCompleteBox.ItemTemplate>
  <DataTemplate>
  <StackPanel>
  <TextBlock Text="{Binding}" />
  </StackPanel>
  </DataTemplate>
  </input:AutoCompleteBox.ItemTemplate>
  </input:AutoCompleteBox>

  private void AutoBox_Populating(object sender, System.Windows.Controls.PopulatingEventArgs e)
  {
  e.Cancel = true;
  src = objMessage.GetAutoStrings(AutoBox.Text);
  AutoBox.ItemsSource = list;//list里面读取到string集合了
  AutoBox.PopulateComplete();
  }
界面输入数据时,数据不会显示出来,不知道哪里出问题了???

------解决方案--------------------
AutoBox_Populating事件需要在构造函数中调用进行数据初始化。

试试:

XML code

<UserControl xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"  x:Class="SL3_test1.SilverlightControl23"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:my="clr-namespace:SL3_test1"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <my:ColorConverter x:Name="cc1"/>
        </Grid.Resources>
        <StackPanel>
            <input:AutoCompleteBox Name="acb1" ValueMemberBinding="{Binding Name}">
                <input:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" Foreground="{Binding Status,Converter={StaticResource cc1}}"/>
                    </DataTemplate>
                </input:AutoCompleteBox.ItemTemplate>
            </input:AutoCompleteBox>
        </StackPanel>
    </Grid>
</UserControl>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: