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

RB

Vista - A question in itemscontrol : to control the gridsplitter

 
 
07-14-2006   #1
wisenighthsu@ulead.com.tw


 

A question in itemscontrol : to control the gridsplitter

Dear all:

I wrote a class based on ItemsControl, and i also wrote its
ControlTemplate.
In ControlTemplate, I use a Grid to place the items.Like below

<Grid IsItemsHost="True"/>

I segment the grid to an 1*2 dimention, and uesd a GridSplitter to
control it.
But the GridSplitter can't not work in the ItemsControl.
Could somebody have the experience to help me.


My System SpecsSystem Spec
07-14-2006   #2
Marcus


 

Re: A question in itemscontrol : to control the gridsplitter

Can you post more detailed code/markup of your setup so we can help you
a little more effectivelly.

wisenighthsu@ulead.com.tw wrote:
> Dear all:
>
> I wrote a class based on ItemsControl, and i also wrote its
> ControlTemplate.
> In ControlTemplate, I use a Grid to place the items.Like below
>
> <Grid IsItemsHost="True"/>
>
> I segment the grid to an 1*2 dimention, and uesd a GridSplitter to
> control it.
> But the GridSplitter can't not work in the ItemsControl.
> Could somebody have the experience to help me.


My System SpecsSystem Spec
07-16-2006   #3
wisenighthsu@ulead.com.tw


 

Re: A question in itemscontrol : to control the gridsplitter

sorry Marcus, I should write it detail.

<!-------------------the controltemplate:------------->
<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>

<!----------------------XAML--------------------------->
<local:MyControl Width="200" Height="200">
<Button Grid.Row="0"/>
<Button Grid.Row="1"/>
<GridSplitter Grid.Row="1"/>
</local:MyControl>

like this.

The problem is I can't use the GridSplitter to resize the
rowdefinition.
Does someone have the experience like this to help me?

My System SpecsSystem Spec
07-16-2006   #4
wisenighthsu@ulead.com.tw


 

Re: A question in itemscontrol : to control the gridsplitter

I rewrite it more detail. Mycontrol is an class base on ItemsControl.
I want to use the gridsplitter to change the size of the tow button.
But it can't work.

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>
<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>
<Grid>
<local:MyControl Width="200" Height="200">
<Button Grid.Row="0"/>
<Button Grid.Row="1" Margin="0,5,0,0"/>
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch"
Height="5" VerticalAlignment="Top"/>
</local:MyControl>
</Grid>
</Window>

My System SpecsSystem Spec
07-16-2006   #5
wisenighthsu@ulead.com.tw


 

Re: A question in itemscontrol : to control the gridsplitter


wisenighthsu@ulead.com.tw 寫道:

I rewrite it more detail. Mycontrol is an class base on ItemsControl.
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

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

RB


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