UWP VS2017 Raspberry Pi3 - Configuration of SerialPort and Beybinding to TextBox
$10-30 USD
Đã đóng
Đã đăng vào gần 7 năm trước
$10-30 USD
Thanh toán khi bàn giao
Attached is a project created in VS2017. It is a Windows Universal Platform project thats goal is to run on a Raspberry Pi3
The project got 2 problems
* Serial port configuration
* Keybinding to TextBox
SerialPort
During development I want to use virtual comports (se attached file)
I configure the virtual comports to be a bridge. COM1 will talk to COM2 using a virtual null-modem. During testing I will send/receive from COM1 and my mockup will respond at COM2.
====> How do I configure the Comport OPEN(). I cant find the virtual port(s). They are visible in Device Manager and I am able to access then in C#.Net but not UWP.
Keybinding
The textbox will use input from a "keyboard emulating device" that sends a serialnumber and ends the string with Enter. ( 1234567890 + Enter)
I have tried to use "code-behind" to catch the Enter-key but my solution will fire twice and its allowed to fire only once.
====> Create a more XAML solution
This is a my best try.. But I did not work in UWP
Here is an approach that to me seems quite straightforward, and easier that adding an AttachedBehaviour (which is also a valid solution). We use the default UpdateSourceTrigger (LostFocus for TextBox), and then add an InputBinding to the Enter Key, bound to a command.
The xaml is as follows
<TextBox Grid.Row="0" Text="{Binding Txt1}" Height="30" Width="150">
<[login to view URL]>
<KeyBinding Gesture="Enter"
Command="{Binding UpdateText1Command}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type TextBox}},Path=Text}" />
</[login to view URL]>
</TextBox>
Then the Command methods are
Private Function CanExecuteUpdateText1(ByVal param As Object) As Boolean
Return True
End Function
Private Sub ExecuteUpdateText1(ByVal param As Object)
If TypeOf param Is String Then
Txt1 = CType(param, String)
End If
End Sub
And the TextBox is bound to the Property
Public Property Txt1 As String
Get
Return _txt1
End Get
Set(value As String)
_txt1 = value
OnPropertyChanged("Txt1")
End Set
End Property
Source copied from [login to view URL]
Hello,
Thanks for posting. I am a qualified and dedicated embedded developer. I create hardware and software for Raspberry. I should be able to help in both issues.
I always value keeping good and timely communication.
Availability : Full Day 24*7 hr and can start work immediately and right away..
Kind Regards
Mahammad