我不能讓下面的工作情況: 我有一個類,用下面的實現:問題的Silverlight ComboBoxItem結合
public class SelectionItem<T> : ViewModelBase where T : Entity
{
private bool? _isSelected;
public bool? IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
RaisePropertyChanged("IsSelected");
}
}
public T Item { get; set; }
}
而且我有我的視圖模型以下屬性:
private IEnumerable<SelectionItem<DB_Aux_Pessoas>> _vendedores;
public IEnumerable<SelectionItem<DB_Aux_Pessoas>> Vendedores
{
get
{
return _vendedores;
}
set
{
_vendedores = value;
RaisePropertyChanged("Vendedores");
}
}
然後,在我看來,我的組合框:
<ComboBox Margin="3,0,0,0"
Height="23"
Width="200"
ItemsSource="{Binding Vendedores, Mode=TwoWay}"
Grid.Column="1"
Grid.Row="1"
HorizontalAlignment="Left">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" />
<TextBlock Text="{Binding Item.NomeRazaoSocial}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
但是,當我CH對ComboBoxItem上的CheckBox進行調整,但它不反映屬性。
爲DB_Aux_Pessoas的代碼如下:
[MetadataTypeAttribute(typeof(DB_Aux_Pessoas.DB_Aux_PessoasMetadata))]
public partial class DB_Aux_Pessoas
{
// This class allows you to attach custom attributes to properties
// of the DB_Aux_Pessoas class.
//
// For example, the following marks the Xyz property as a
// required property and specifies the format for valid values:
// [Required]
// [RegularExpression("[A-Z][A-Za-z0-9]*")]
// [StringLength(32)]
// public string Xyz { get; set; }
internal sealed class DB_Aux_PessoasMetadata
{
// Metadata classes are not meant to be instantiated.
private DB_Aux_PessoasMetadata()
{
}
public Nullable<short> Cliente { get; set; }
public string Id_Numero { get; set; }
public string NomeRazaoSocial { get; set; }
public Nullable<short> Supervisor { get; set; }
public Nullable<short> Vendedor { get; set; }
}
}
我在做什麼錯在這裏? Tks提前。
必須有一些其他細節丟失,因爲我無法重現您的錯誤。你可以給DB_Aux_Pessoas的代碼,也可以在你說「不反映在屬性上」時,你能告訴我們你是如何尋找這個改變的嗎?謝謝。 – 2011-03-22 01:12:39
嗨,馬丁,我已經編輯了DB_Aux_Pessoas代碼的問題。問題是我有一個ComboBox,它的ItemsSource是SelectionItem的集合,屬性IsSelected綁定到ComboBox的ItemTemplate的CheckBox。當我檢查CheckBox並讀取ItemsSource的值時,IsSelected屬性沒有更改值。 – 2011-03-22 13:39:40