从AutoCompleteBox中选择项目后,从头开始显示文本 [英] Showing Text from begining after selecting item from AutoCompleteBox
问题描述
我正在使用自动完成"框,从下拉列表中选择项目后,该项目未显示开始文本,仅显示了结束文本
假设文本框的宽度为100,如果自动完成中选中项的长度较大,则自动完成而不是显示从开始显示的文本,而是仅显示字符串的末尾(即文本框中的可见部分)
请帮助我...
Hi ,
I am using Autocomplete box ,once after selecting item from dropdown the item is not showing starting text ,it''s showing only ending text
Assume the textbox width is 100 ,if the length of selected item in autocomplete is large ,the autocomplete instead of showing text from starting it''s showing only the last end of string (ie visible part in textbox)
plz help me in this ...
推荐答案
AutoCompleteBox
由TextBox
和少量组件组成.该控件不公开TextBox控件.因此,除非您派生并自定义控件,否则您将无法实现自己的想法.
从AutoCompleteBox
派生AutoCompleteBoxEx
并添加公共属性/方法以返回控件内部使用的TextBox
.然后,您可以尝试以下示例.
试试,
AutoCompleteBox
is made up ofTextBox
and few components. The control does not expose the TextBox control. So you cannot achieve your idea unless you derived and customize the control.
DerivedAutoCompleteBoxEx
fromAutoCompleteBox
and add a public Property/Method to return theTextBox
used inside the control. Then you can try the below example.
Try,
textBox.CaretIndex = 0;
在您从自动完成"框中选择项目之后
after you selected the item from the AutoComplete box
您好,我在一周之前获得了解决方案,因此自动完成"框由许多内容组成,其中文本框也是其中之一,因此我们需要获取该文本框通过遍历树来自动完成
在autocomplte框的最后一个焦点内,我们可以像
那样放置
hi I got solution before week itself ,the Autocomplete box is composed of many things among that textbox is also one ,so we need to get the textbox from the autocomplete by traversing the tree
Inside the last focus of autocomplte box we can put like
AutoCompleteBox autoObject = sender as AutoCompleteBox;
TextBox textObject = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(autoObject, 0), 0) as TextBox;
textObject.SelectAll();
textObject.SelectionLength = 0;
这样文本的开头部分将在自动完成的最后一个焦点上显示
干杯,
so that the begining part of text will be diplayed on autocomplete last focus
Cheers,
这篇关于从AutoCompleteBox中选择项目后,从头开始显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!