[Silverlight getting started series] there is no problem of stretching stretch after accordion is embedded in Treeview.

Source: Internet
Author: User

In the previous article, we implemented how to embed the accordion control provided in the Silverlight toolkit into a Treeview. However, the problem is that the Treeview cannot be automatically strentch, the width and length cannot be the same as the available width of accordionitem, and cannot be automatically stretched. How can this problem be solved? That is to set a grid. This control has a feature that will adapt to the available size. We will add the grid:

 <  Usercontrol  X: Class  = "Accordintreeviewtest. mainpage"  
Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: d = "Http://schemas.microsoft.com/expression/blend/2008"
Xmlns: MC = "Http://schemas.openxmlformats.org/markup-compatibility/2006"
MC: ignorable = "D"
Xmlns: Controls = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
D: designheight = "300" D: designwidth = "400" Xmlns: Toolkit = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" >

< Grid X: Name = "Layoutroot" Background = "White" >
< Toolkit: accordion Height = "236" Horizontalalignment = "Left" Margin = "44,28, 0, 0" Name = "Accordion1" Verticalalignment = "TOP" Width = "244" >
< Toolkit: accordionitem Header = "Menu 1" >
< Toolkit: accordionitem. contenttemplate >
< Datatemplate >
< Grid Background = "Red" Loaded = "Grid_loaded" >
< Controls: Treeview Margin = "1" Borderthickness = "0" >
< Controls: treeviewitem Header = "Node1" >
< Controls: treeviewitem Header = "Node1.1" />
< Controls: treeviewitem Header = "Node1.2" />
< Controls: treeviewitem Header = "Node1.3" />
</ Controls: treeviewitem >
< Controls: treeviewitem Header = "Node2" >
< Controls: treeviewitem Header = "Node2.1 _ testlonglonglonglonglongnode" />
< Controls: treeviewitem Header = "Node2.2" />
< Controls: treeviewitem Header = "Node2.3" />
</ Controls: treeviewitem >
</ Controls: Treeview >
</ Grid >
</ Datatemplate >
</ Toolkit: accordionitem. contenttemplate >
</ Toolkit: accordionitem >
< Toolkit: accordionitem Content = "Ontent2" Header = "Menu 2" > </ Toolkit: accordionitem >
< Toolkit: accordionitem Content = "Ontent3" Header = "Menu 3" > </ Toolkit: accordionitem >
< Toolkit: accordionitem Content = "Ontent4" Header = "Menu 4" > </ Toolkit: accordionitem >
</ Toolkit: accordion >
</ Grid >
</ Usercontrol >

There is an event later, in *. XAML. CS:

Private VoidGrid_loaded (ObjectSender, routedeventargs E)
{
Grid=SenderAsGrid;
Grid. Width=Accordion1.actualwidth- 5;
}

Although ugly, do you have a better solution?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.