xaml部分:
<ComboBox Margin="10" Padding="5" BorderBrush="LightGray" BorderThickness="1" FontSize="15" SelectedItem="{Binding Shuttle1Value}">
<ComboBoxItem IsSelected="True">请选择</ComboBoxItem>
<ComboBoxItem>去等待位</ComboBoxItem>
<ComboBoxItem>去接驳位</ComboBoxItem>
<ComboBoxItem>入库</ComboBoxItem>
<ComboBoxItem>出库</ComboBoxItem>
<ComboBoxItem>停止</ComboBoxItem>
<ComboBoxItem>复位</ComboBoxItem>
<ComboBoxItem>复位报警后清状态</ComboBoxItem>
<ComboBoxItem>充电</ComboBoxItem>
<ComboBoxItem>更新位置</ComboBoxItem>
</ComboBox>
<Button Command="{Binding TriggerCommand}" Content="下发" />
c#代码(viewmodel)部分:
public class DeviceManageViewModel : BindableBase
{
public DelegateCommand TriggerCommand { get; private set; }
private ComboBoxItem shuttle1Value;
public ComboBoxItem Shuttle1Value
{
get { return shuttle1Value; }
set { shuttle1Value = value; RaisePropertyChanged(); }
}
public DeviceManageViewModel()
{
TriggerCommand = new DelegateCommand(Shuttle1Trigger);
}
public void Shuttle1Trigger()
{
var y=Shuttle1Value.Content;
MessageBox.Show(y.ToString());
}
}