This is a migrated thread and some comments may be shown as answers.

DropDownContent with WindowsFormsHost

2 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pov Ser
Top achievements
Rank 1
Pov Ser asked on 21 May 2014, 07:46 PM
I'm using DropDownButton to display Winform or HWND window, but it seems that it does not display any Winform in DropDownContent

Here is example:
<Window
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="MainWindow"
     xmlns:Forms32="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
 
        <telerik:RadDropDownButton Content="Browser" HorizontalAlignment="Left" Height="Auto" IsOpen="False" Margin="36,21,0,0" VerticalAlignment="Top" Width="Auto" DropDownWidth="800" DropDownHeight="600">
            <telerik:RadDropDownButton.DropDownContent>
                <WindowsFormsHost>
                    <Forms32:WebBrowser Url="google.com"></Forms32:WebBrowser>
                </WindowsFormsHost>
            </telerik:RadDropDownButton.DropDownContent>
        </telerik:RadDropDownButton>
         
        <telerik:RadDropDownButton Content="Button" HorizontalAlignment="Left" Height="Auto" IsOpen="False" Margin="129,21,0,0" VerticalAlignment="Top" Width="Auto">
            <telerik:RadDropDownButton.DropDownContent>
                <WindowsFormsHost>
                    <Forms32:TextBox Text="Test Text Box"></Forms32:TextBox>
                </WindowsFormsHost>
            </telerik:RadDropDownButton.DropDownContent>
        </telerik:RadDropDownButton>
 
    </Grid>
</Window>

2 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 26 May 2014, 09:28 AM
Hi Pov,
The problem is that WindowsFormsHost doesn't work in Popups with AllowsTransparency = True and by default we set it to true in code behind. What you can do is handle the loaded event and change it manually:
private void OnDropDownButtonLoaded(object sender, RoutedEventArgs e)
{
    var dropDownButton = sender as RadDropDownButton;
    if (dropDownButton == null) return;
 
    var popup = dropDownButton.ChildrenOfType<Popup>().FirstOrDefault();
    if (popup != null)
        popup.AllowsTransparency = false;
}
I hope I was able to help you.

Regards,
Zarko
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Pov Ser
Top achievements
Rank 1
answered on 27 May 2014, 08:33 AM
It works. Thank you kind.
Tags
General Discussions
Asked by
Pov Ser
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Pov Ser
Top achievements
Rank 1
Share this question
or