How do I add an AFDatabasePicker control (like what we have in PI System Explorer) in my .NET WPF UI?
You can't do it at design time...well unless you have some kind of wrapper.
However, if you have a container where you want the control placed then you can do it via code...basically hosting in as a Win Forms control within WPF.
I just put one on the Grid...you need to reference "WindowsFormsIntegration" and "System.Windows.Forms" in your WPF application, then you can do the following type of thing...
private void Window_Loaded(object sender, RoutedEventArgs e)
System.Windows.Forms.Integration.WindowsFormsHost host =
OSIsoft.AF.UI.PISystemPicker WhichPISystem = new OSIsoft.AF.UI.PISystemPicker();
host.Child = WhichPISystem;
It just means you need to manage events etc directly in code rather than in the XAML designer.
The AFDatabasePicker control is available in the OSISOFT.AF.UI library. Once you add this reference to your project you will be able to choose that item from the toolbox.
Our learning channel video has a demo of this (~9:30) Not authorized to view the specified discussion 1205
I can easily add the OSIsoft controls in a Windows Forms application, but am having trouble adding the controls into my Windows WPF application. Any ideas how?
Great! I have added the Windows Forms Control in a WPF grid.
However, can I build a WPF custom control for AF and PI server picker? Where are all the icons used in the Windows Forms AF/PI controls? I want to reuse them in my WPF custom control.
You can do it like this.
Include this code in the Window Loaded event.
WindowsFormsHost host =new WindowsFormsHost();
AFDatabasePicker picker = new AFDatabasePicker();
PISystem sys = new PISystems().DefaultPISystem;
host.Child = picker;
where grid1 is the name of a grid in the WPF Window.
I wasn't aware that it is possible to use Windows Forms Controls inside XAML. Thank you for teaching me differently.
The only thing that I was struggling with a little, was to find the proper using clause for the Forms integration because it was not obvious to me based on the assembly name (WindowsFormsIntegration):
Gregor Beck wrote: The only thing that I was struggling with a little, was to find the proper using clause for the Forms integration because it was not obvious to me based on the assembly name (WindowsFormsIntegration):
Gregor Beck wrote:
My earlier post shows you the FQ namespace for that.
I obviously overlooked your earlier post. Sorry!
Retrieving data ...