Related Topics: PowerBuilder, Microsoft Cloud

PowerBuilder: Article

Using a WPF Docking Manager in a PowerBuilder WPF Target

Everything you need to create state-of-the-art GUI applications

In a previous PBDJ article, we looked at using a third-party control, a ribbon control in particular, in a PowerBuilder WPF target. One of the other "most requested" features people have asked for is the capability to provide docking windows in their PowerBuilder applications. In this article, we're going to look at how we can do that in a PowerBuilder WPF application using a third-party docking manager.

The particular docking manager I'm going to use is the AvalonDock, an open source project on CodePlex (http://avalondock.codeplex.com/). At the time of this writing, the current version is 1.3.3571. However, that one has some dependencies on Visual Studio 2010 and .NET Framework 4.0 libraries. PowerBuilder .NET 12 is based on the Visual Studio 2008 isolated shell, so I'm using an older build (1.1.1509) that doesn't have these dependencies.

First, we'll add the AvalonDock assembly and a reference to a new WPF application. Create a new WPF window and add the AvalonDock namespace to the Usings property for the new window. I called that new window w_frame, and coded the open event of the application object to open it. I then dropped a DockingManager control onto the window. Next create a menu (I called mine m_menu) and associate that menu with the new window as well.

I then edited the XAML for the new window to provide a couple of RowDefinitions and to add a StatusBar to the bottom of the window. My modified window XAML looks like this:

<RowDefinition Height="*"/>
<RowDefinition Height="24"/>
<my:DockingManager x:Name="dockingmanager1" Grid.Row="0">
<StatusBar Grid.Row="1">
<StatusBarItem Content="Docking Panel Demo"/>

The bottom RowDefinition is 24 units high, and the top RowDefinition takes up whatever remaining space there is (the majority of the window). The DockingManager is located in the top RowDefintion (Rows is a zero-based collection), and the StatusBar is assigned to the bottom RowDefinition.

I'm also going to create three instance variables in the window for the ResizingPanel, a DocumentPanel, and a DockablePanel:

ResizingPanel resPanel
DockablePane dockPane
DocumentPane documentPane

In the open event of the window I'll instantiate those items, associate the DockablePane and the DocumentPane to the ResizingPanel, and finally associate the ResizingPanel to the DockManager we added in the designer:

resPanel = create ResizingPanel
resPanel.Orientation = System.Windows.Controls.Orientation.Horizontal!
dockPane = create DockablePane
documentPane = create DocumentPane
dockingmanager1.Content = resPanel

In the menu, I'll add two menu items: one to open a document "sheet" into the DocumentPane and another to open a "tab" in the DockablePane. They'll just fire events on the window that will actually do the work though. For example:

ParentWindow.event dynamic ue_opensheet()

Here's where it gets interesting. What the docking manager wants to see opening into the DockablePane and the DocumentPane are objects derived from the DockableContent and DocumentContent classes. What we're going to do is create a couple of PowerBuilder custom visual user objects, and then create an inner control on each of those classes. In an existing application, you would need to modify the XAML for your window ancestor classes to accomplish the same thing. The XAML for the resulting objects, u_document and u_panel, look like this Listings 1 and 2. (Listings 1-3 can be downloaded here.)

Now we can go back to w_frame and code the events that open a "sheet" (u_document) and a "tab" (u_panel) (see Listing 3).

Run the app, select the options to open a sheet and a panel two times each, and you should have something that looks similar to Figure 1. Some things to note:

  • Dockable items are capable of autohiding.
  • Dockable items can also be "floated" and moved outside of the frame, even onto a second monitor, giving multi-monitor support.
  • If an item is given a name, the DockingManager can serialize the layout of those items and store it so that it can be reloaded the next time the application runs. The result is that the user's preference for the pane layouts can be remembered between sessions.
  • At any time you can drag an item and use the layout indicators to create new docking groups or move the item onto an existing docking group (see Figure 2).

There you have it - multiple-monitor support, docking panes, autohiding panes and the ability to store and retrieve layouts. Everything you need to create state-of-the-art GUI applications.

Note: Special thanks go out to Peter Conn of the U.S. Census Bureau. His presentation of how he implemented something similar using a commercial third-party docking manager at TechWave 2010 is what prompted me to look into doing it with an open source implementation. He also helped me through some of the stumbling blocks I ran into as I was putting it together.

More Stories By Bruce Armstrong

Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Most Recent Comments
russf0426 10/31/12 12:40:00 PM EDT


Can you elaborate on your choice of avalon? Is your example not possible with the default dockpanel?

acartagenas 08/21/11 04:45:00 AM EDT

Hi Bruce,

This is a very good article for us PB developers. However, the word doc does not exists on the web server.


Latest Stories
​Blockchain, also known as Distributed Ledger Technology (DLT), can be used for more than just crypto currencies. This presentation discusses how blockchain and the Internet of Things (IOT) can be used for several supply chain management and logistics use cases. Real world examples that utilize the open source project Hyperledger will be discussed.
Gym Solutions is a software as a service (SaaS) solution purpose-built to service the fitness industry, with over 1000 clients servicing over 2 million gym members across 40 countries making Perfect Gym Solutions one of the largest and fastest growing SaaS applications in the fitness industry. Their platform is a comprehensive package of modern modular products for the management of fitness clubs, sports facilities and gyms an end- to end solution, revolutionising the way that gyms are managed. ...
Enterprises are universally struggling to understand where the new tools and methodologies of DevOps fit into their organizations, and are universally making the same mistakes. These mistakes are not unavoidable, and in fact, avoiding them gifts an organization with sustained competitive advantage, just like it did for Japanese Manufacturing Post WWII.
Eric Taylor, a former hacker, reveals what he's learned about cybersecurity. Taylor's life as a hacker began when he was just 12 years old and playing video games at home. Russian hackers are notorious for their hacking skills, but one American says he hacked a Russian cyber gang at just 15 years old. The government eventually caught up with Taylor and he pleaded guilty to posting the personal information on the internet, among other charges. Eric Taylor, who went by the nickname Cosmo...
There's no doubt that blockchain technology is a powerful tool for the enterprise, but bringing it mainstream has not been without challenges. As VP of Technology at 8base, Andrei is working to make developing a blockchain application accessible to anyone. With better tools, entrepreneurs and developers can work together to quickly and effectively launch applications that integrate smart contracts and blockchain technology. This will ultimately accelerate blockchain adoption on a global scale.
As the fourth industrial revolution continues to march forward, key questions remain related to the protection of software, cloud, AI, and automation intellectual property. Recent developments in Supreme Court and lower court case law will be reviewed to explain the intricacies of what inventions are eligible for patent protection, how copyright law may be used to protect application programming interfaces (APIs), and the extent to which trademark and trade secret law may have expanded relev...
The Blockchain Benchmark asks and answers the questions many people want to know about the state of Blockchain: What are the biggest barriers? What was your motivation to get involved? When will it mainstream? Who are the true influencers? What are its top use cases? Who will win over the next 5 years? How will the future unfold? And 20+ other valuable questions.
Ivo Lukas is the Founder/CEO for 24Notion. 24Notion is the first integrated marketing/digital PR & lifestyle agency with special emphasis on giving back to the global communities. With a broad understanding the art of non- traditional marketing, new media, communications and social influence. 24Notion ranked #12 in Corporate Philanthropy nominated by Portland Business Journal Book of List.
SUSE is a German-based, multinational, open-source software company that develops and sells Linux products to business customers. Founded in 1992, it was the first company to market Linux for the enterprise. Founded in 1992, SUSE is the world’s first provider of an Enterprise Linux distribution. Today, thousands of businesses worldwide rely on SUSE for their mission-critical computing and IT management needs.
Provide an overview of the capabilities of Azure Stack allowing you or your customers to adopt truly consistent Hybrid Cloud capabilities to deliver greater productivity in your cloud world. Ultan Kinahan is on a member of the Global Black Belt team at Microsoft with a focus on Azure Stack Hybrid Cloud. Ultan has been in the Azure team since the beginning, Has held roles in Engineering, Sales and now consults with both small to medium size business and the worlds largest organizations on how to ...
SAP is the world leader in enterprise applications in terms of software and software-related service revenue. Based on market capitalization, we are the world's third largest independent software manufacturer. Harness the power of your data and accelerate trusted outcome-driven innovation by developing intelligent and live solutions for real-time decisions and actions on a single data copy. Support next-generation transactional and analytical processing with a broad set of advanced analytics - r...
Mid-sized companies will be pleased with StorageCraft's low cost for this solution compared to others in the market. There are no startup fees, our solution has a predictable monthly cost, highly competitive pricing and offers ongoing value for our partners month after month. By enabling pooling and StorageCraft's 30-days of free virtualization the company removes several concerns surrounding machine size management and disaster recovery testing costs that add to the complexity of implementing a...
Blockchain is a new buzzword that promises to revolutionize the way we manage data. If the data is stored in a blockchain there is no need for a middleman - the distributed database is stored on multiple and there is no need to have a centralized server that will ensure that the transactions can be trusted. The best way to understand how a blockchain works is to build one. During this presentation, we'll start with covering the basics (hash, nounce, block, smart contracts) and then we'll create ...
In addition to 22 Keynotes and General Sessions, attend all FinTechEXPO Blockchain "education sessions" plus 40 in two tracks: (1) Enterprise Cloud (2) Digital Transformation. PRICE EXPIRES AUGUST 31, 2018. Ticket prices: ($295-Aug 31) ($395-Oct 31) ($495-Nov 12) ($995-Walk-in) Does NOT include lunch.
DevOpsSUMMIT at CloudEXPO will expand the DevOps community, enable a wide sharing of knowledge, and educate delegates and technology providers alike. Recent research has shown that DevOps dramatically reduces development time, the amount of enterprise IT professionals put out fires, and support time generally. Time spent on infrastructure development is significantly increased, and DevOps practitioners report more software releases and higher quality. Sponsors of DevOpsSUMMIT at CloudEXPO will b...