我使用的是 Visual Studio 2017 社区版/.NET Framework 4.6.1/WPF。顺便提一句。我使用 MVVM。
我的目标是在Combobox 中显示所有可用的串行端口。我已经实现了这一点,但现在我想让组合框在打开下拉菜单或连接新设备时自动更新。因此,我需要一些财产来制作Binding我的ViewModel.
在 MSDN 上,我发现 Combobox.DroppedDown-Property 对我来说听起来不错,但我不能使用它,找不到 DroppedDown...(是System.Windows.Forms正确的参考吗?)。
你发现我的错误还是你有更好的解决方案?
谢谢!
<UserControl x:Class="HC_SR04_MPU6050.View.SerialView_MPU_6050"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HC_SR04_MPU6050.View"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="MPU-6050" HorizontalAlignment="Center"/>
<Label Grid.Row="0" Grid.Column="3" Content="Y-ROT[°]" HorizontalAlignment="Center"/>
<Button Command="{Binding Connect_Clicked}" Grid.Row="1" Grid.Column="0" Content="Connect" Height="20" Width="60" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6" ToolTip="Opens/Connects the selected COM-PORT"/>
<Button Command="{Binding Measure_Clicked}" Grid.Row="1" Grid.Column="1" Content="MEASURE" Height="20" Width="60" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6" ToolTip="Starts the Measurement routine"/>
<Button Command="{Binding Stop_Clicked}" Grid.Row="1" Grid.Column="2" Content="STOP" Height="20" Width="60" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6" ToolTip="Stops the communication/ Closes/Disconnects the selected COM-PORT"/>
冉冉说
相关分类