WPF GetPortNames() 绑定系统资源
程序员文章站
2022-06-07 17:59:51
...
<Window x:Class="SerialPortBinding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ports="clr-namespace:System.IO.Ports;assembly=System"
Title="MainWindow" SizeToContent="WidthAndHeight">
<Window.Resources>
<ObjectDataProvider ObjectType="{x:Type ports:SerialPort}" MethodName="GetPortNames" x:Key="portNames"/>
</Window.Resources>
<ComboBox ItemsSource="{Binding Source={StaticResource portNames}}"/>
</Window>
上一篇: WPF下拉框绑定数据
下一篇: linux system函数深入理解