The WPF model is definitely one of composition. The Windows Forms model of
All new articles provide code in C# and VB.NET.
"Glenn" <Glenn@discussions.microsoft.com> wrote in message
news:3B8106BF-A15A-4814-9C02-E0C38F6576EA@microsoft.com...
>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@discussions.microsoft.com> wrote in message
>> news:AEBF40D4-57EC-4DD9-954A-67C06DA70B49@microsoft.com...
>> > 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?
>> >>
>>