Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Winform UserControl's gradient background not displayed when in WPF component... why??

$
0
0

Hello,

We have a Winforms application that we are looking to convert to WPF.  For the time being we are building a WPF Window shell and in one of the areas we are simply bringing one of our Winform UserControls.  The xaml looks like:

<Grid>
  <WindowsFormsHost>
    <wf:MyComponent x:Name="aia"/>      
  </WindowsFormsHost>
</Grid>

This is a UserControl where we use a gradient for the background:

protected override void OnPaint(PaintEventArgs e) {
   base.OnPaint(e);

   LinearGradientBrush lb = new LinearGradientBrush(this.ClientRectangle, Color.LightBlue, Color.Blue, LinearGradientMode.Horizontal);
   e.Graphics.FillRectangle(lb, this.ClientRectangle);
   lb.Dispose();
}

This works fine when the UserControl was within our Winform's application but when it is in our WPF application, the gradient does not get rendered although I can see that the method is being called.

Does anyone know why it isn't getting rendered within a WPF control?  Thanks for any thoughts.

- Peter


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>