Click here to Skip to main content
15,936,349 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello fellow coders,
I have a WPF page and I'm stuck. I want to have a border around a tree view with corner radius running along the left side of window on load. The page loads 600 x 750, but allows full screen. When the user maximizes the screen, I want the border to stay top 10 (which is does), left 7 (which is does), bottom 10 - WHICH IS DOES NOT (aka: code below wrapped in <Canvas></Canvas>). As you can see, I tried that, but it doesnt work. What I think I'm trying to ask for is Height = Auto or 100% or * or something that fills the screen 10 from the top and bottom (Canvas.Top="10" Canvas.Bottom="10" Canvas.Left="7") and scales properly on resize. Thoughts?


C#
<Grid Height="254" Width="140" Canvas.Top="5" Canvas.Left="5" />
        <Border BorderBrush="#FF252A30" CornerRadius="5,5,5,5" BorderThickness="2,2,2,2"
                Height="545" Canvas.Left="7" Canvas.Top="10" Canvas.Bottom="10" Width="204">
            <TreeView x:Name="TreeView1" HorizontalAlignment="Left"
                      VerticalAlignment="Top" Width="184" Height="525" Margin="8,8,0,0">
                <TreeViewItem Header="Header" IsExpanded="False">
                    <TreeViewItem Header="Smaller Header" IsExpanded="False">
                        <TreeViewItem Header="New" />
                        <TreeViewItem Header="Search" />
                        <TreeViewItem Header="Transfer" />
                    </TreeViewItem>
                    <TreeViewItem Header="Smaller Header 2" IsExpanded="False">
                        <TreeViewItem Header="1" />
                        <TreeViewItem Header="2" />
                        <TreeViewItem Header="3" />
                        <TreeViewItem Header="4" />
                    </TreeViewItem>
                </TreeViewItem>
// whole bunch more tree views...
            </TreeView>
        </Border>
Posted

1 solution

XML
<grid>
            <grid.columndefinitions>
                <columndefinition width="475" />
                <columndefinition width="*" />
            </grid.columndefinitions>
            <grid.rowdefinitions>
                <rowdefinition height="*" />
                <rowdefinition height="200" />
            </grid.rowdefinitions>
//CODE stuff here
// like <dockpanel grid.column="0" grid.row="0" mode="hold" /></grid>


Now, when I expand the treeview, the border grows with it. I'd still like to find a way to maximize the border on full screen, but this will work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900