Silverlight自动完成框 [英] Silverlight AutoComplete box
本文介绍了Silverlight自动完成框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
在AutCompleteBox中我用复选框显示多个项目。如果我在autocompletebox中选择了两个以上的项目,我会连接所选项目并显示为AutoCompleteBox的选定文本。
c#code:
public void SetString()
{
string str = ;
foreach (RecurDays项目 ObjSchldRecurDaysList)
{
if (item.IsChecked)
{
str = str + item.SchldDayDesc.Substring( 0 , 3 )+ ,;
}
}
if (str!= )
str = str.Substring( 0 ,str.Length - 1 跨度>);
SchldRecurDaysText = str;
}
xaml代码:
< cc:IDAutoComplete 名称 = tbxRecurOn1001 Grid.Row = 10 Grid.Column = 5
< span class =code-attribute> < span class =code-attribute> 文本 = {Binding SchldRecurDaysText,Mode = TwoWay} ItemsSource = {Binding ObjSchldRecurDaysList,Mode = TwoWay} < span class =code-attribute>
< span class =code-attribute> SelectedItem = {Binding ObjSchldRecurDaysSelectedData,Mode = TwoWay}
< cc:IDAutoComplete.ItemTemplate >
< DataTemplate >
< CheckBox 名称 < span class =code-keyword> = 复选框 内容 = {Binding SchldDayDesc,Mode = OneWay} <跨度cl ass =code-attribute> HorizontalAlignment = Stretch HorizontalContentAlignment = 拉伸
< span class =code-attribute> < span class =code-attribute> IsChecked = {Binding Path = IsChecked,Mode = TwoWay} MinWidth = 150
< span class =code-attribute> FontStyle = 正常 前景 = 黑色 >
< / CheckBox >
< / DataTemplate >
< / cc:IDAutoComplete.ItemTemplate >
< / cc:IDAutoComplete >
文本值获取值为星期一,星期二,星期三,但在视图中不显示。请帮助我....
解决方案
实施INotifyPropertyChanged事件...
以下是一些样品
whats-the-concept-behind-inotifypropertychanged [ ^ ]
implement-inotifypropertychanged.html [ ^ ]
简单示例-的-inotifypropertychanged.aspx [ ^ ]
< pre lang =cs> public string SchldRecurDaysText
{
get { return _SchldRecurDaysText; }
set
{
_SchldRecurDaysText = value ;
通知( SchldRecurDaysText);
}
}
protected void 通知( string propertyName)
{
ConfirmPropertyName (propertyName的);
if (propertyChanged!= null )
{
propertyChanged( this , new PropertyChangedEventArgs(propertyName));
}
}
Hi
In AutCompleteBox i''m Displaying multiple items with check box. if i''m choosing more than two items in autocompletebox, i concatenate the selected items and show as selected text of AutoCompleteBox.
c# code:
public void SetString()
{
string str = "";
foreach (RecurDays item in ObjSchldRecurDaysList)
{
if (item.IsChecked)
{
str = str + item.SchldDayDesc.Substring(0, 3) + ",";
}
}
if (str != "")
str = str.Substring(0, str.Length - 1);
SchldRecurDaysText = str;
}
xaml code:
<cc:IDAutoComplete Name="tbxRecurOn1001" Grid.Row="10" Grid.Column="5"
Text="{Binding SchldRecurDaysText, Mode=TwoWay}" ItemsSource="{Binding ObjSchldRecurDaysList,Mode=TwoWay}"
SelectedItem="{Binding ObjSchldRecurDaysSelectedData,Mode=TwoWay}"
<cc:IDAutoComplete.ItemTemplate>
<DataTemplate>
<CheckBox Name="checkbox" Content="{Binding SchldDayDesc,Mode=OneWay}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" MinWidth="150"
FontStyle="Normal" Foreground="Black" >
</CheckBox>
</DataTemplate>
</cc:IDAutoComplete.ItemTemplate>
</cc:IDAutoComplete>
The Text Value get value as "Mon,Tue,wed" but it is not displyed in View. please help me....
解决方案
Implement INotifyPropertyChanged event...
Here are some samples
whats-the-concept-behind-inotifypropertychanged[^]
implementing-inotifypropertychanged.html[^]
simple-example-of-inotifypropertychanged.aspx[^]
public string SchldRecurDaysText { get { return _SchldRecurDaysText; } set { _SchldRecurDaysText = value; Notify("SchldRecurDaysText"); } }
protected void Notify(string propertyName) { ConfirmPropertyName(propertyName); if (propertyChanged != null) { propertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
这篇关于Silverlight自动完成框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文