.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems to show WMF in WPF

1 REPLY 1
Reply
Message 1 of 2
Anonymous
516 Views, 1 Reply

Problems to show WMF in WPF

Hi all,

I know you may think this is the wrong forum for a kind of Windows Presentation Foundation question.
But maybe there are spezial thinks to keep in mind with wmf images.

We have DWGs which will be inserted as blocks and we want to show pictures of them in a product catalogue. We tried to use BMP for them but the quality wasn't good enought. So we decidet to use wmf instead. We used them in WinForms before in a picture box. Now we are using WPF and I'm trying to show them. The WPF does not work so I tried to use the picturebox as before:

XAML Code:

Window ...
> xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms">
>xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration">
...
>wfi:WindowsFormsHost Height="100">
>wf:PictureBox Width="100" Height="100" x:Name="picturebox1">
>/wf:PictureBox>
>/wfi:WindowsFormsHost>
...

(Sorry but the open tag for > does not work)

Code behind is the same as in WinForms used before...
{code}
this.picturebox1.Image =System.Drawing.Image.FromFile(@"C:\Files\test.WMF");
{code}

...but it does not work.

How can I show a wmf file in wpf?
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Ahh it works like described above. The only missing thing is the SizeMode and the Max values.
{code}

wfi:WindowsFormsHost MaxWidth="300" MaxHeight="300">
wf:PictureBox SizeMode="StretchImage" x:Name="picturebox1">
/wf:PictureBox>
/wfi:WindowsFormsHost>
{code}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost