![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | A question about ItemsControl I wrote a class "MyContorl" based on ItemsControl. In the controltemplate, I use a Grid(1*2) to place the items. Then I put two buttons and a gridsplitter into MyContorl. I want to use the gridsplitter to change the size of the tow button. But it can't work. I want it work like the last two button and gridsplitter /*-----------MyContorl Class--------*/ namespace ItemsControlTest { class MyControl : ItemsControl { public MyControl() { } } } <Window x:Class="ItemsControlTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="ItemsControlTest" Height="300" Width="300" xmlns:local="clr-namespace:ItemsControlTest" > <Window.Resources> <!--/////////////////////////////////Contorl Template/////////////////////////////--> <Style x:Key="{x:Type local:MyControl}" TargetType="{x:Type local:MyControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:MyControl}"> <Grid x:Name="MyGrid" IsItemsHost="True"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <StackPanel> <local:MyControl Width="200" Height="200"> <Button Grid.Row="0" Height="Auto" Width="Auto"/> <Button Grid.Row="1" Height="Auto" Width="Auto" Margin="0,5,0,0"/> <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Height="5" VerticalAlignment="Top"/> </local:MyControl> <!--///////////////////the result i want//////////////////////////////--> <Grid Width="200" Height="200" Margin="0,10,0,0"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Button Grid.Row="0" Height="Auto" Width="Auto"/> <Button Grid.Row="1" Height="Auto" Width="Auto" Margin="0,5,0,0"/> <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Height="5" VerticalAlignment="Top"/> </Grid> </StackPanel> </Window> |
My System Specs![]() |