private void SendMsg_Click(object sender, RoutedEventArgs e) { if (SendMsgId.SelectedValue == null || SendMsgType.SelectedValue == null) { MessageBox.Show("Please fill all fields out.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } byte[] ascii = System.Text.Encoding.ASCII.GetBytes(SendMsgAsciiPayload.Text); if (AppendNullAscii.IsChecked == true) { ascii = ByteArrayUtils.AddByteToArray(ascii, 00); } SPPMessage msg = new SPPMessage { Id = (SPPMessage.MessageIds)SendMsgId.SelectedValue, Payload = (PayloadTabs.SelectedItem as TabItem).Name == "AsciiTab" ? ascii : SendMsgPayload.Text.HexStringToByteArray(), Type = (SPPMessage.MsgType)SendMsgType.SelectedValue }; BluetoothService.Instance.SendAsync(msg); }