如何在WindowsFormsHost
?
<WindowsFormsHost Name="wfbutton1" Width="200" Height="100" Background="White" Visibility="Visible" >
<wf:Button Height="23" Left="145" Top="127" wf:Name="button1" Width="75"
Click="button1_Click" Visible="True" FlatStyle="Flat"
BackgroundImage="C:\\Users\\Kvint\\Desktop\\Background.bmp" />
</WindowsFormsHost >
答案 0 :(得分:0)
为您的按钮命名,就像任何其他WPF元素一样:
<WindowsFormsHost ... >
<wf:Button x:Name="button1" ... />
</WindowsFormsHost >
然后在代码隐藏中引用它:
button1.BackgroundImage
= System.Drawing.Image.FromFile(@"C:\Users\Kvint\Desktop\Background.bmp");
如果您正在寻找纯粹的XAML方法,我会将其留给其他人。在这种情况下,我不确定它是否可能。