silverlight-4.0 – Autocompletebox SelectedText Bug

silverlight-4.0 – Autocompletebox SelectedText Bug,第1张

概述我想绑定AutocompleteBox的SelectedText和SelectedItem属性,因为我的客户端希望能够输入文本并从列表中进行选择.它运作正常,但…… MainPage有一个DataGrid.当我从网格中选择一条记录(即SelectedItem)时,我想在d出窗口的AutocompleteBox中设置它.有时它可以工作,但有时却没有. 我该怎么办这个问题? 这是我的XAML: <Sd 我想绑定autocompletebox的SelectedText和SelectedItem属性,因为我的客户端希望能够输入文本并从列表中进行选择.它运作正常,但……

MainPage有一个DataGrID.当我从网格中选择一条记录(即SelectedItem)时,我想在d出窗口的autocompletebox中设置它.有时它可以工作,但有时却没有.

我该怎么办这个问题?

这是我的XAML:

<Sdk:autocompletebox GrID.Column="3" GrID.Row="3" Height="18" WIDth="150"      IsTextCompletionEnabled="True" TabIndex="9" HorizontalAlignment="left"     Text="{Binding Elementname=ResEdit,Path=DataContext.SelectedDemoText,Mode=TwoWay}"     ItemsSource="{Binding Elementname=ResEdit,Path=DataContext.DemoList,Mode=OneWay}"     ItemTemplate="{StaticResource DemoTemplate}"     ValueMemberPath="DemoCode"      LostFocus="autocompletebox_LostFocus"     margin="0,21,0" padding="0">  </Sdk:autocompletebox>

此属性在我的视图模型中并绑定到DataGrID:

public InvoicesDTO SelectedInvoice{    get { return _selectedInvoice; }    set    {        SelectedInvoice = value;        SelectedDomoText = SelectedInvoice.DemoText.Trim();        RaisePropertyChanged("SelectedInvoice");    }}
解决方法 您不应在自动完成中同时使用函数SelectedText和SelectedItem.这是autocompletebox的一个错误…..更好的方法是在GotFocus和LossFocus上设置文本框和autocompletebox的可见性.这种方式你会直截了当地解决你的问题

private voID DemoautoComplete_LostFocus(object sender,RoutedEventArgs e)            {                DemoTextBox.Visibility = Visibility.Visible;                DemoautoComplete.Visibility = Visibility.Collapsed;                DemoTextBox.Text = OCRautoComplete.Text;                ((DemoVM)this.DataContext).SelectedDemoText = DemoautoComplete.Text;            }private voID DemoTextBox_GotFocus(object sender,RoutedEventArgs e)    {        DemoautoComplete.Text = OctTextBox.Text;        DemoTextBox.Visibility = Visibility.Collapsed;        DemoautoComplete.Visibility = Visibility.Visible;        DemoautoComplete.Focus();    }
总结

以上是内存溢出为你收集整理的silverlight-4.0 – Autocompletebox SelectedText Bug全部内容,希望文章能够帮你解决silverlight-4.0 – Autocompletebox SelectedText Bug所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1000929.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存