Re: WPF Background issue

Tech-Archive recommends: Speed Up your PC by fixing your registry



The WPF model is definitely one of composition. The Windows Forms model of override and conquer is outmoded.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Glenn" <Glenn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:3B8106BF-A15A-4814-9C02-E0C38F6576EA@xxxxxxxxxxxxxxxx
I already switched to that design. I wasn't really expecting a magic fix,
just confirmation that I wasn't missing something.



"Bob Powell [MVP]" wrote:

Rather than deriving from ScrollViewer create a new control to draw your
graphics and place it in the Content of a ScrollViewer.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Glenn" <Glenn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AEBF40D4-57EC-4DD9-954A-67C06DA70B49@xxxxxxxxxxxxxxxx
> Here's some code to reproduce this problem:
>
> Window1.xaml:
>
> <Window x:Class="BackgroundIssue.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation";
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml";
> xmlns:test="clr-namespace:BackgroundIssue"
> Title="Background Issue" Height="375" Width="464"
> xmlns:my="clr-namespace:System;assembly=mscorlib">
> <Grid>
> <test:CustomViewer x:Name="customViewer1"
> HorizontalAlignment="Left"
> Width="238" Background="Red" />
> </Grid>
> </Window>
>
>
> CustomWindow.cs:
>
> using System;
> using System.Windows.Controls;
> using System.Windows.Media;
> using System.Windows;
>
> namespace BackgroundIssue
> {
> public class CustomViewer : ScrollViewer
> {
> public CustomViewer()
> {
> this.VerticalScrollBarVisibility = > ScrollBarVisibility.Hidden;
> }
>
> protected override void
> OnRender(System.Windows.Media.DrawingContext
> drawingContext)
> {
> drawingContext.DrawRectangle(null, new Pen(new
> SolidColorBrush(Colors.Navy), 10), new Rect(20, 20, 400, 300));
> }
>
> }
> }
>
>
> This will create a window with the control on half of it. A rectangle > is
> drawn larger than the control so you can see that the red background is
> covering what is drawn in the OnRender method.
>
> -Glenn
>
>
>
> "Bob Powell [MVP]" wrote:
>
>> Post some code...
>>
>> -- >> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Ramuseco Limited .NET consulting
>> http://www.ramuseco.com
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> Glenn wrote:
>> > Hi,
>> >
>> > I've created a control that derives from ScrollViewer and override >> > the
>> > OnRender method to draw onto the control. However, if the >> > Background
>> > property is set, the background always draws on top of whatever I >> > draw.
>> >
>> > Even if I don't call base.OnRender the background is drawn, so I'm >> > not
>> > sure
>> > what is drawing the background or why it would be drawn after >> > OnRender
>> > is
>> > called. Does anyone have any ideas?
>>


.



Relevant Pages

  • Re: Visual Inheritence Sux
    ... You're not suggesting that NNTP is a technological solution are you? ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... >> Ramuseco Limited .NET consulting ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Sending compressed image bits to Printers?
    ... Ramuseco Limited .NET consulting ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... myImage is generated in code - and was originally the result of a "new Bitmap" call. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Dpi problem
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... >> Ramuseco Limited .NET consulting ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: WPF Background issue
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... This will create a window with the control on half of it. ... covering what is drawn in the OnRender method. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Reusable Component, how to implement it?
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... >> ShowInTaskbar property set true. ... >> Ramuseco Limited .NET consulting ...
    (microsoft.public.dotnet.framework.windowsforms)