Professional OPC
Development Tools

logos

Invoking Browsing Dialogs in WPF Application

More
14 May 2019 19:26 #7363 by gkalipershad
This is exactly what I was looking for.

Thanks!

Please Log in or Create an account to join the conversation.

More
14 May 2019 19:24 #7362 by support
Hello,
you are right that there currently isn't any example that shows this, but it is easy to achieve.

The dialogs are Windows Forms components. They can be used from WPF, but WPF does not support non-visual components which represent the dialogs, therefore the dialog objects need to be instantiated and set up from the code. I have created this example now.

If the user wants to re-create it, he/she needs to reference the System.Windows.Forms, and BaseLib, BaseLibForms, and EasyOpcForms assemblies, and the assembly for the particular OPC technology (EasyOpcClassic or EasyOpcUA), in the WPF project. Then, the dialog can be invoked as in the code below; in my case, I have put the invocation code into the event handler on a button click.

using System.Windows;
using OpcLabs.EasyOpc.UA.Forms.Browsing;
 
namespace UAWpfRunDialog
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var dataDialog = new UADataDialog
            {
                EndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            };
            if (dataDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                return;
            NodeIdTextBlock.Text = dataDialog.NodeDescriptor.NodeId.ToString();
        }
    }
}


I hope this helps
The following user(s) said Thank You: gkalipershad

Please Log in or Create an account to join the conversation.

More
14 May 2019 15:09 #7361 by gkalipershad
Hello,

Perhaps I am missing this from the documentation, but I was wondering if there was any sample code that shows how to invoke the Browsing Dialogs in a WPF Appication.

Thanks,
GK

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.164 seconds

      

 Recommend this on Google