Hi.
I believe you can use such popups for more than just tooltips, that's the whole point of WPF, you can do anything.
Except get the darn textboxes to accept keystrokes !.
Okay so I trawled around a fair bit to find a solution and saw lots of references to Plumbing in the keyboard events from the hosting windows form to your WPF contained window by calling
ElementHost.EnableModelessKeyboardInterop
But I couldn't get this to work with a wpf popup, I just couldn't get the "Window" and I tried a few things.
Anyway I accidentally found a work around. If you have a panel from which you have a popup, and you have a textbox on that panel, and you click into it and type in some text, then you trigger your popup to come up - youre textbox will work and be plumbed in. Its as if the text box on teh base control triggers all the plumbing.
Kind of hard to explain, but here's the code
<stackpanel background="LightSeaGreen" orientation="Horizontal">
<textbox x:name="mytextbox" width="0" xmlns:x="#unknown" />
<textblock x:name="blessme" text="This is the popup button." mouseenter="popupUC_Loaded" xmlns:x="#unknown">
<textblock.triggers>
<eventtrigger routedevent="Mouse.MouseUp">
<eventtrigger.actions>
<beginstoryboard>
<storyboard>
<booleananimationusingkeyframes storyboard.targetname="ConnectPopup">
Storyboard.TargetProperty="IsOpen">
<discretebooleankeyframe keytime="00:00:00" value="True" />
</booleananimationusingkeyframes>
</storyboard>
</beginstoryboard>
</eventtrigger.actions>
</eventtrigger>
</textblock.triggers>
</textblock>
</stackpanel>
<popup x:name="ConnectPopup" placementtarget="{Binding ElementName=ConnectPopupTrigger}" xmlns:x="#unknown">
PopupAnimation="Slide" AllowsTransparency="True" StaysOpen="False">
<border margin="2 2,0,3" borderthickness="1" borderbrush="DarkSlateGray">
<stackpanel orientation="Vertical" margin="0,0,3,3">
<stackpanel orientation="Horizontal">
<label width="70">User Name:</label>
<textbox text="{Binding FXAllUserName}" width="120" margin="1" />
</stackpanel>
<stackpanel orientation="Horizontal">
<label width="70">Password:</label>
<passwordbox x:name="mypassword" width="120" margin="1" />
</stackpanel>
</stackpanel>
</border>
</popup>
void popupUC_Loaded(object sender, RoutedEventArgs e)
{
UIElement element = mytextbox as UIElement;
if (element != null)
{
Boolean success = element.Focus(); //Always returns false and doesn't take focus.
}
}
All I had to do programtically was get the hidden text box to gain focuss for an instant and the textbox in your popup would contain text.
Try it without the hidden text box "mytextbox" and you'll see it doesn't work.
Ok a poor work around, but just means you add a zero width text box and a quick callback and it all works.
Enjoy.