![](/img/trans.png)
[英]Binding in Silverlight 4 to ComboBox in DataGridColumn
[英]Silverlight Combobox Binding to Element
我有一個Silverlight Telerik RadComboBox。 我正在設計一個主詳細頁面。
在網格中,我有人員列表-網格中的一列是稱呼。 當我單擊網格中的項目時,下面的所有文本框將根據其綁定進行填充。
但是用組合框,我想知道是否可以像這樣綁定它。
SelectedItem="{Binding ElementName=PersonGrid, Path=SelectedItem.SalutationLookupValue, Mode=TwoWay}"
我猜你不能這樣。 我想這樣做,但是我想我需要將selecteditem綁定到SelectedSalutation並在為網格設置所選項目時進行設置。
public Person SelectedPersonResult
{
get { return _selectedPersonResult; }
set
{
SetObject(ref _selectedPersonResult, value, "SelectedPersonResult");
if (_selectedSalutationResult != null)
{
SelectedSalutation = SalutationList.Where(x => x.Value == SelectedPersonResult.SalutationLookupValue).FirstOrDefault();
}
}
}
同樣,我更喜歡用第一種方法(在xaml中)做,但是我猜想用第二種方法是唯一的方法?
如果您的ComboBox
的行為類似於標准行為,則第一種方法應該可以工作,但您不應綁定到SelectedItem
,正確的屬性將是SelectedValue
。 (該組合框是否具有這種屬性?)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.