I am creating a custom control which is derived from ItemsControl and now I am facing a problem. When I used my control at sample level with more item means, scrollviewer is not displayed(both H & V). Below is the code(Just sample) for my custom control:
<!--Parent-->
<Style TargetType="{x:Type local:Parent}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Parent}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer>
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--MainChild-->
<Style TargetType="{x:Type local:MainChild}">
<Setter Property="Height" Value="430"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MainChild}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ItemsPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--InnerChild-->
<Style TargetType="{x:Type local:InnerChild}">
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="100"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:InnerChild}">
--------------------------------------
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I used the above control in my sample with many childrens, but scrollviewer is not displayed.
Sample having my control as,
<local:Parent Background="Yellow" >
<local:MainChild Margin="20" Background="Green">
<local:InnerChild Content="Item1" Background="#FF008C00"/>
<local:InnerChild Content="Item2" Background="#FF008C00"/>
<local:InnerChild Content="Item3" Background="#FF008C00"/>
<local:InnerChild Content="Item4" Background="#FF008C00"/>
<local:InnerChild Content="Item5" Background="#FF008C00"/>
<local:InnerChild Content="Item6" Background="#FF008C00"/>
<local:InnerChild Content="Item7" Background="#FF008C00"/>
<local:InnerChild Content="Item8" Background="#FF008C00"/>
</local:MainChild>
</local:Parent>
Like this i used it in sample and it extends horizontally, but no horizontal scroll bar is displayed.
Any suggestions are welcome?