Hi. Anybody know a way to use the viewer inside a WPF Window?
Thanks a lot.
GdViewer with WPF
Re: GdViewer with WPF
1) Add a reference to the GdPicture.NET.dll to your project.
2) Wrap the GdViewer in a WindowsFormsHost like so:
3) Then in your code-behind do something like this:
2) Wrap the GdViewer in a WindowsFormsHost like so:
Code: Select all
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PaperValet"
xmlns:wfh="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:gdPicture="clr-namespace:GdPicture;assembly=GdPicture.Net"
mc:Ignorable="d"
x:Class="PaperValet.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top">
<MenuItem Header="MenuItem"/>
</Menu>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar/>
</ToolBarTray>
<StatusBar DockPanel.Dock="Bottom">
<TextBlock><Run Text="Status Bar"/></TextBlock>
</StatusBar>
<StackPanel DockPanel.Dock="Left">
<Button Content="AccountsHere"/>
</StackPanel>
[b] <WindowsFormsHost Margin="5" Grid.Row="0">
<gdPicture:GdViewer x:Name="gdViewer" BackColor="Aquamarine"></gdPicture:GdViewer>
</WindowsFormsHost>[/b]
</DockPanel>
</Window>
Code: Select all
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
if (gdViewer != null)
{
bool result = gdViewer.SetLicenseNumber("XXX"); // Replace with your key!
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
GdPictureStatus status = gdViewer.DisplayFromFile(
System.IO.Path.Combine(System.IO.Path.GetDirectoryName(exePath), "TestImage.png"));
if (status == GdPictureStatus.OK)
{
gdViewer.MouseMode = ViewerMouseMode.MouseModePan;
gdViewer.ScrollBars = true;
int pageCount = gdViewer.PageCount;
}
}
}
Who is online
Users browsing this forum: No registered users and 1 guest