Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Invoking Browsing Dialogs in WPF Application

More
11 Aug 2021 08:43 #10106 by support
Similar code can also be found in the (C#) examples solutions, in the WPF/WpfEasyOpcUADemo project. The "Browse servers" and "browse data" buttons on the main WPF form invoke the (WinForms-based) OPC browsing dialogs.

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

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.057 seconds