8,735
社区成员
发帖
与我相关
我的任务
分享
public class SysType:NotificationObject
{
private int selectValue;
public int SelectValue
{
get
{ return selectValue; }
set
{
selectValue = value;
this.RaisePropertyChanged("selectValue");
}
}
private string displayName;
public string DisplayName
{
get
{ return displayName; }
set
{
displayName = value;
this.RaisePropertyChanged("displayName");
}
}
}
<ComboBox Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="10,143,0,0"
ItemsSource="{Binding ListSysType,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="DisplayName" SelectedValue="{Binding SelectValue}"
x:Name="CobSysType" VerticalAlignment="Top" Width="120" >
</ComboBox>
public class LocationRoad
{
public int ID { set; get; }
public string Code { set; get; }
public string Info { set; get; }
}
//
/// 当ComboBox选中项更改时发生
///
private LocationRoad _selectLocation;
public LocationRoad SelectLocation
{
get
{
return this._selectLocation;
}
set
{
this._selectLocation = value;
if (this.PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("SelectLocation"));
}
}
private ObservableCollection _locationRoad = null;
public ObservableCollection LocationSource
{
get
{
if (this._locationRoad == null)
{
this._locationRoad = new ObservableCollection() {
new LocationRoad() { ID = 1, Code = "NGQ", Info = "南岗区" },
new LocationRoad() { ID = 2, Code = "DLQ", Info = "道里区" },
new LocationRoad() { ID = 3, Code = "DWQ", Info = "道外区" },
new LocationRoad() { ID = 4, Code = "PFQ", Info = "平房区" },
new LocationRoad() { ID = 5, Code = "XFQ", Info = "香坊区" },
};
}
return this._locationRoad;
}
set
{
this._locationRoad = value;
if (this.PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("LocationSource"));
}
}
<ComboBox Margin="-16,3,0,5" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Name="cboxLocationKeyword"
ItemsSource="{Binding LocationSource,Mode=OneWay}"
SelectedValuePath="ID"
DisplayMemberPath="Info"
SelectedItem="{Binding SelectLocation}" />
CobSysType.SelectedItem