This project is read-only.

How to make the scroll bar always visible?

Mar 8, 2010 at 7:32 AM

I put the WPG control in a UserControl and did not set the width and height properties, because I want the

WPG to resize along with its container.But when I ran it , the scroll bar of WPG didn't show up, and middle button of

mouse did not work, so part of the properties can not be seen.

Does the scroll bar of WPG only shows up when the height property is explicitly set?

How to make the scroll bar always visible so I can scroll up and down while WPG can resize along with its container?

Coordinator
Mar 8, 2010 at 10:31 AM

Normaly the Scrollbar should be shown when needed...

Maybe send me a bit of your source....

Mar 8, 2010 at 11:36 AM
<Window x:Class="WPGDemoApp.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpg="clr-namespace:WPG;assembly=WPG"
        Title="Window1" Height="300" Width="300">
    <StackPanel>
        <Button x:Name="btn">button for test</Button>
        <wpg:PropertyGrid Instance="{Binding ElementName=btn}"></wpg:PropertyGrid>
    </StackPanel>
</Window>

The code is like this snippet.

I did not set the height of the WPG control,so it can resize when the window is resized.

But the scroll bar did not show up when I ran the code above, so some of the button's properties can not be seen.

Coordinator
Mar 8, 2010 at 1:13 PM

You have to use a Dock panel:

 

<DockPanel VerticalAlignment="Stretch" >
        <Button DockPanel.Dock="Top" x:Name="btn">button for test</Button>
        <wpg:PropertyGrid  DockPanel.Dock="Top" Instance="{Binding ElementName=btn}"  VerticalAlignment="Stretch"></wpg:PropertyGrid>
    </DockPanel>

<DockPanel VerticalAlignment="Stretch" >

        <Button DockPanel.Dock="Top" x:Name="btn">button for test</Button>

        <wpg:PropertyGrid  DockPanel.Dock="Top" Instance="{Binding ElementName=btn}"  VerticalAlignment="Stretch"></wpg:PropertyGrid>

    </DockPanel>

because StckPanel tells it Childrens they can use infinity height, so this will not work!

 

Mar 8, 2010 at 1:38 PM

Oh,thank you!

Sorry for my lack of WPF basic knowledge, I'm still a rookie⊙﹏⊙

Coordinator
Mar 8, 2010 at 2:12 PM

me also....

i'm doing it since 2 months, but the knowledge is growing...  ;-)

Mar 8, 2010 at 2:38 PM

really?

then I assume you have been programming for a while(otherwise you must be a fast learner).

I have not graduate from college yet.

Coordinator
Mar 8, 2010 at 2:41 PM

Yes, I'm programming since 17 years (since I was 12)

Mar 9, 2010 at 7:14 AM

Wow......

My first Hello-world program was written only 3 years ago......