Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - A question about ItemsControl

 
 
Old 07-19-2006   #1 (permalink)
wisenighthsu@ulead.com.tw


 
 

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 SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46