I'm using NetMQ for remoting a device. It is a Server/Client based architecture.
I implemented a GUI with WPF and Xaml which let me send commands as strings and receive answers also as strings.
The Host Application has a Dictionary<int, cmdStruct> ListOfCommands()
.
int is an ID and cmdStruct is a Class that defines the command structure which is: string cmdText
, string cmdHelpText
and delegate cmdAction
.
public static Dictionary<int, CommandStructure> CollectionOfCommands = new Dictionary<int, CommandStructure>();
public class CommandStructure
{
public string mCommandName;
public string mCommandHelpText;
public Func<string> mFunc;
When I send a command "list" it is supposed to show all the commands in the Dictionary, and I access it with it key and values to show only the ID, cmdText and cmdHelpText. Then I put them into a stringBuilder
using append.
if (_clientCommand == "?" || _clientCommand == "list")
{
foreach (var cmd in CollectionOfCommands)
{
stringBuilder.Append(cmd.Key + Tab);
stringBuilder.Append(cmd.Value.mCommandName + Tab);
stringBuilder.Append(cmd.Value.mCommandHelpText + NewLine);
_serverResponse = stringBuilder.ToString();
}
}
Everything worked fine here unless I tried to change the ListBox to a ComboBox (a DropDownList) to show all available commands on it. But the problem it doesn't work. I got the commands listed vertically and not horizontally one below the other.
private void ListCommands(object sender, RoutedEventArgs e)
{
Client.SendFrame(list);
Thread.Sleep(100);
var response = Client.ReceiveFrameString();
//ListHelp is a listbox
ListHelp.Items.Add(response);
//IF I PUT IT IN A COMBOBOX IT SHOWN AS DESCRIBED
ComboBox.ItemsSource = response;
}