UserControl resizing at runtime - c#

Hi fellow programmers,
I'm working on a WPF software that uses a Canvas to display and move graphic objects.
These graphic objects are UserControls containing labels or rectangles :
<UserControl x:Class="DashEditor.Views.MovableObject"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
<Grid Name="ControlLayout">
<StackPanel x:Name="DisplayPanel" >
<Canvas x:Name="graphicObjectCanvas" Width="100" Height="50">
<Viewbox x:Name="graphicObjectViewBox" Width="100" Height="50" IsEnabled="False" Canvas.Left="0" Canvas.Top="0" Stretch="Fill"/>
</Canvas>
</StackPanel>
</Grid>
I need to resize these UserControls, I saw examples with thumbs but I can't figure out how to use it in a UserControl.
Thank you for your help !

OK, I found a working solution to resize my canvas graphic objects.
I added a thumb into my usercontrol which become visible when a graphic object is selected :
<Grid Name="ControlLayout">
<StackPanel x:Name="DisplayPanel">
<Border x:Name="CanvasBorder" BorderThickness="1">
<Canvas x:Name="graphicObjectCanvas" Width="100" Height="50" Background="Aquamarine">
<Viewbox x:Name="graphicObjectViewBox" Width="100" Height="50" IsEnabled="False" Stretch="Fill"/>
<Thumb x:Name="myThumb" Canvas.Left="80" Canvas.Top="30" Width="20" Height="20" DragDelta="myThumb_DragDelta" Visibility="Hidden"
PreviewMouseLeftButtonDown="myThumb_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="myThumb_PreviewMouseLeftButtonUp" BorderBrush="Blue" BorderThickness="2"/>
</Canvas>
</Border>
</StackPanel>
</Grid>
And this is the code behind that changes my graphic object's properties :
private void myThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
double yadjust = graphicObjectViewBox.Height + e.VerticalChange;
double xadjust = graphicObjectViewBox.Width + e.HorizontalChange;
if ((xadjust >= 0) && (yadjust >= 0))
{
graphicObjectViewBox.Width = xadjust;
graphicObjectViewBox.Height = yadjust;
graphicObjectCanvas.Width = xadjust;
graphicObjectCanvas.Height = yadjust;
Width = (int)xadjust;
Height = (int)yadjust;
XapParent.Width = (int)xadjust;
XapParent.Height = (int)yadjust;
Canvas.SetLeft(myThumb, Canvas.GetLeft(myThumb) + e.HorizontalChange);
Canvas.SetTop(myThumb, Canvas.GetTop(myThumb) + e.VerticalChange);
}
}

Related

Show controls in Scrollviewer row along the Scrollbar

So I have this scenario in which I am showing a Grid inside a ScrollViewer.
I want to show a combobox and an image along the scrollbar in a way that it doesn't effect the scrolling functionality,
Something like this:
Currently whenever the scrollviewer becomes visible it appears in a new row, how can I show it along the controls in the same row?
Here is my xaml design:
<DockPanel LastChildFill="True">
<!--Top Panel-->
<Grid DockPanel.Dock="Top">
--GridContent
</Grid>
<!--Bottom Panel-->
<Grid DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column ="0">
</ComboBox>
<Image Grid.Column="1">
</Image>
</Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch" >
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
-- Grid Content
</Grid>
</ScrollViewer>
</DockPanel>
Currently it appears like this :
I haven't looked at doing this in XAML, but you can do it like this in the code behind:
public partial class MainWindow : Window
{
private void IncrementColumn(UIElement element)
{
Grid.SetColumn(element, Grid.GetColumn(element) + 1);
}
public MainWindow()
{
InitializeComponent();
scrollPanel.ApplyTemplate();
var horizontal = scrollPanel.Template.FindName("PART_HorizontalScrollBar", scrollPanel) as ScrollBar;
var vertical = scrollPanel.Template.FindName("PART_VerticalScrollBar", scrollPanel) as ScrollBar;
var presenter = scrollPanel.Template.FindName("PART_ScrollContentPresenter", scrollPanel) as ScrollContentPresenter;
var corner = scrollPanel.Template.FindName("Corner", scrollPanel) as Rectangle;
var grid = corner.Parent as Grid;
grid.ColumnDefinitions.Insert(0, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
IncrementColumn(horizontal);
IncrementColumn(vertical);
IncrementColumn(corner);
Grid.SetColumnSpan(presenter, 2);
var panel = new StackPanel() { Orientation = Orientation.Horizontal };
panel.Children.Add(new ComboBox());
panel.Children.Add(new Image());
Grid.SetRow(panel, 1);
Grid.SetColumn(panel, 0);
grid.Children.Add(panel);
}
}
Here's the XAML to go with it:
<Window x:Class="WpfApplication1.MainWindow"
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"
Title="MainWindow" Height="150" Width="525">
<ScrollViewer
Name="scrollPanel"
HorizontalScrollBarVisibility="Visible"
HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Auto"
VerticalAlignment="Stretch">
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Image Source="C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"/>
</Grid>
</ScrollViewer>
</Window>

Wpf Universal App Windows 10 VS 2015 How to handle multiple KeyDown events.

I am creating WPF universal app game "Pong" on VS 2015.
Design:
<Page
x:Class="Pong.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Pong"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Canvas Name="MainCanavas" HorizontalAlignment="Center" Height="640" VerticalAlignment="Center" Width="1024" Background="Black">
<Rectangle Height="100" Width="20" Fill="White" Name="LeftPad" Canvas.Top="{Binding YPosition}" HorizontalAlignment="Center" />
<Rectangle Height="100" Width="20" Fill="White" Name="RightPad" Canvas.Top="{Binding YPosition}" Canvas.Left="1005"></Rectangle>
<Line X1="500" X2="500" Y2="630" Y1="15" StrokeThickness="5" StrokeDashArray="2" Stroke="White"></Line>
<Ellipse Width="30" Height="30" Name="Ball" Fill="White" StrokeThickness="0.1" DataContext="{Binding Path=ball}" Canvas.Left="{Binding X}" Canvas.Top="{Binding Y}" RenderTransformOrigin="0.48,0.587"></Ellipse>
<TextBlock x:Name="LeftScore" Canvas.Left="374" TextWrapping="Wrap" Text="0" Foreground="White" Canvas.Top="10" Height="134" Width="62" FontSize="96" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" RenderTransformOrigin="0.481,0.499"/>
<TextBlock x:Name="RightScore" Canvas.Left="564" TextWrapping="Wrap" Text="0" Foreground="White" Canvas.Top="10" Height="134" Width="62" FontSize="96" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" RenderTransformOrigin="0.481,0.499"/>
</Canvas>
It's a 2 player game, so I wrote two paddle events, for left and right pads:
private void LeftPad_KeyDown(object sender, KeyEventArgs e)
{
// Left pad events
if (e.VirtualKey == VirtualKey.W)
{
leftPad.YPosition -= padMoveBy;
}
if (e.VirtualKey == VirtualKey.S)
{
leftPad.YPosition += padMoveBy;
}
}
private void RightPad_KeyDown(object sender, KeyEventArgs e)
{
// Right pad events
if (e.VirtualKey == VirtualKey.Up)
{
rightPad.YPosition -= padMoveBy;
}
if (e.VirtualKey == VirtualKey.Down)
{
rightPad.YPosition += padMoveBy;
}
}
Main contructor:
public MainPage()
{
this.InitializeComponent();
CoreWindow.GetForCurrentThread().KeyDown += LeftPad_KeyDown;
CoreWindow.GetForCurrentThread().KeyDown += RightPad_KeyDown;
Ball.DataContext = ball;
LeftPad.DataContext = leftPad;
RightPad.DataContext = rightPad;
LeftScore.DataContext = leftScore;
RightScore.DataContext = rightScore;
}
When I run the program, I can move just one paddle at the time, even though I have two events.
Help would be nice...

Get listView item number from selected item in wpf and c#

I have a ListView of images and i would know which image is selected from left click mouse.
I don't find any way to do this and i'm blocked on this code where it's impossible cast ListViewItem to Image for obtain index in list.
c#:
private void listView_Click(object sender, MouseButtonEventArgs e)
{
var hitTestResult = VisualTreeHelper.HitTest(listViewExercise, e.GetPosition(null));
var selectedItem = hitTestResult.VisualHit;
while (selectedItem != null)
{
if (selectedItem is System.Windows.Controls.ListViewItem)
{
break;
}
selectedItem = VisualTreeHelper.GetParent(selectedItem);
}
Image image = (Image)selectedItem;
Console.WriteLine(image.Source);
}
XAML:
<k:KinectRegion x:Name="ChoiceExercise" Background="Black" >
<DockPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<k:KinectUserViewer Grid.Row="0" Height="100" HorizontalAlignment="Center" VerticalAlignment="Top"/>
<ScrollViewer k:KinectRegion.IsHorizontalRailEnabled="True" k:KinectRegion.IsScrollInertiaEnabled="true" VerticalScrollBarVisibility="Disabled" Grid.Row="1" >
<ListView Grid.Row="1">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
<Viewbox Width="300" >
<Image Stretch="UniformToFill" Source="Images/la.jpg"/>
</Viewbox>
<Viewbox Width="300">
<Image Stretch="UniformToFill" Source="Images/end exercise win.jpg"/>
</Viewbox>
</ListView>
</ScrollViewer>
</Grid>
</DockPanel>
</k:KinectRegion>
There is an easier way to obtain the item container, and once you do that, you just need to extract the DataContext to get the item from the ItemsSource:
private void listView_Click(object sender, MouseButtonEventArgs e)
{
var source = e.OriginalSource as DependencyObject;
if (source == null)
return;
var selectedItem = ItemsControl.ContainerFromElement((ItemsControl)sender, source)
as FrameworkElement;
if (selectedItem == null)
return;
var image = selectedItem.DataContext as Image;
if (image != null)
Console.WriteLine(image.Source);
}

C# WPF - TransitioningContentControl with App.content

I Work with the theme of MahApps (Metro Dark) I looked the animations of this theme.
I came to a dead end: indeed I created a system to switch between different UserControl, that is to say that I have only one window and clicking on different buttons, I have this or such UserControl. But now I am with this system switch, I have no animation (only the start of the application).
How can I make an animation for each change in UserControl (Keeping Metro theme)?
Somebody ask me : use TransitioningContentControl
But i made my switcher like this :
class Switcher
{
public static UserControl WClient;
public static UserControl WHome;
public static UserControl WDataBase;
public Switcher()
{
WClient = new Windows.Client();
WHome = new Windows.Home();
WDataBase = new Windows.DataBase();
}
public static void currentWindow(UserControl window, string color)
{
Window curApp = Application.Current.MainWindow;
curApp.Content = window;
if (window == WClient)
{
curApp.Title = "CLIENT - INFO-TOOLS - BY NAOGRAFIX";
}
else if (window == WDataBase)
{
curApp.Title = "DATABASE - INFO-TOOLS - BY NAOGRAFIX";
}
else
{
curApp.Title = "HOME - INFO-TOOLS - BY NAOGRAFIX";
}
currentColor(color);
}
}
Now, when i clic on a button (to switch userControl) i use this :
private void BtnDataBase_Click(object sender, RoutedEventArgs e)
{
var color = "Red";
if (DataBase.isConnected) { color = "Green"; }
Switcher.currentWindow(Switcher.WDataBase, color);
}
I use CONTENT, i dont know if i can use TransitioningContentControl
Help :)
Nao*
You do need to use transitioning content control as you have said. You can add that as the direct content of the window then access it by name from the mainwindow and change its content instead.
Xaml
<metro:TransitioningContentControl x:Name="tContent"/>
C#
((ContentControl)curApp.FindName("tContent")).Content = window;
You will need the xml namespace definition
xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
and you can change the transition using the Transition property on TransitioningContentControl
WPF XAML below shows use of MahApps.Metro TransitioningContentControl.
Click on the Content listbox to switch content.
Select the transition effect in the Transition listbox, then change selected Content to see the effect.
<Window x:Class="WpfMahApp.MainWindow"
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"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="800">
<Window.Resources>
<TextBlock x:Key="Content1" Width="400" Height="200" Text="Content 1: TextBox" Background="Aqua" />
<Canvas x:Key="Content2" Width="200" Height="400" Background="DarkOrange">
<Ellipse Fill="YellowGreen" Stroke="Black" Width="100" Height="200" />
<Label Content="Content2: Canvas" />
</Canvas>
<Border x:Key="Content3" Width="100" Height="100" Background="Yellow" BorderBrush="Blue" BorderThickness="2" CornerRadius="4">
<TextBlock Text="Content3: Border" />
</Border>
</Window.Resources>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" >
<CheckBox Margin="4" Content="Is Transitioning" IsChecked="{Binding ElementName=TransitioningContentControl,Path=IsTransitioning , Mode=OneWay}" />
<StackPanel Orientation="Vertical" Margin="8">
<TextBlock Text="Content" FontWeight="Bold"/>
<ListBox Name="ContentSelection" HorizontalAlignment="Left">
<ListBoxItem Content="Content 1" Tag="{StaticResource Content1}" />
<ListBoxItem Content="Content 2" Tag="{StaticResource Content2}" />
<ListBoxItem Content="Content 3" Tag="{StaticResource Content3}" />
</ListBox>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="8">
<TextBlock Text="Transition" FontWeight="Bold" />
<ListBox Name="Transition" HorizontalAlignment="Left">
<ListBoxItem Content="Default" Tag="{x:Static mah:TransitionType.Default}"/>
<ListBoxItem Content="Normal" Tag="{x:Static mah:TransitionType.Normal}"/>
<ListBoxItem Content="Up" Tag="{x:Static mah:TransitionType.Up}"/>
<ListBoxItem Content="Down" Tag="{x:Static mah:TransitionType.Down}"/>
<ListBoxItem Content="Left" Tag="{x:Static mah:TransitionType.Left}" />
<ListBoxItem Content="Right" Tag="{x:Static mah:TransitionType.Right}"/>
<ListBoxItem Content="LeftReplace" Tag="{x:Static mah:TransitionType.LeftReplace}"/>
<ListBoxItem Content="RightReplace" Tag="{x:Static mah:TransitionType.RightReplace}"/>
</ListBox>
</StackPanel>
</StackPanel>
<mah:TransitioningContentControl Margin="8"
Name="TransitioningContentControl"
Background="Beige" BorderBrush="Black" BorderThickness="1"
Content="{Binding ElementName=ContentSelection, Path=SelectedValue.Tag}"
Transition="{Binding ElementName=Transition, Path=SelectedValue.Tag}" />
</StackPanel>
</Window>

Make ListBox size to fit the ItemsPanel used as its ItemsPresenter

I have a custom control ListBox that I would like to adjust its size according to the size of its ItemsPanel. For the items panel, I have a custom control WrapPanel that arranges the items accordingly. As you can see in the screen shot, the ListBox prefers to size itself to its parent control or availableSize.
So then I tried to make a custom control Grid, that had an ItemsSource property that handed the items to its listbox. But that didn't work either. When the Grid would arrange, then the ListBox would Arrange, which would cause the Grid to Arrange and so on.
So my question is, how to I create a custom control that has an ItemsSource property and an ItemsPresenter that sizes itself according to the contents of its children??
You just have to set your ListBox HorizontalAlignment to Left, and VerticalAlignment to Top. This should do the trick.
Simple example :
MainWindow.xaml
<Window x:Class="ListBoxFitItemsPanel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="400" Width="400">
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Red" HorizontalAlignment="Left" VerticalAlignment="Top" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Background="AntiqueWhite" Margin="5" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
</ListBox>
</Window>
EDIT : It also works in a Binding scenario :
MainWindow.xaml
<Window x:Class="ListBoxFitItemsPanel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ListBoxFitItemsPanel"
Title="MainWindow" Height="400" Width="400">
<Window.Resources>
<DataTemplate DataType="{x:Type local:Item}">
<Rectangle Width="100" Height="100" Fill="LightSlateGray" Stroke="Black" StrokeThickness="1" Margin="5" />
</DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding Items}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Red" HorizontalAlignment="Left" VerticalAlignment="Top" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Background="AntiqueWhite" Margin="5" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Window>
MainWindow.xaml.cs
using System.Collections.Generic;
using System.Windows;
namespace ListBoxFitItemsPanel
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
public IEnumerable<Item> Items
{
get
{
for (int i = 0; i < 9; i++)
{
yield return new Item();
}
}
}
}
public class Item { }
}
This is what I had to do to get the functionality I wanted. First I have to create my SquareWrapPanel. This is where the magic happens and arranges my items the way I want.
protected override Size ArrangeOverride(Size finalSize)
{
return ArrangeByChildCount(finalSize);
}
private Size ArrangeByChildCount(Size finalSize)
{
double childWidth = 0;
double childHeight = 0;
foreach (UIElement e in Children)
{
e.Measure(finalSize);
childWidth = e.DesiredSize.Width;
childHeight = e.DesiredSize.Height;
}
if (Children.Count > 0)
{
int square = (int)Math.Sqrt(Children.Count);
int rowCount = square + Children.Count % square;
int columnCount = square;
double height = rowCount * childHeight;
double width = columnCount * childWidth;
Size size = new Size(width, height);
base.ArrangeOverride(size);
return size;
}
else
{
return new Size(300, 300);
}
}
Then I created a custom panel that extended ItemsControl. That way I could bind a collection of items to it. There is nothing in the code behind, but here is the style I had to use.
<Style TargetType="{x:Type local:SquareItemsPanel}" BasedOn="{StaticResource {x:Type ItemsControl}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ItemsControl">
<Border BorderBrush="Black" BorderThickness="2" CornerRadius="4">
<Expander x:Name="exp" Header="View">
<local:SquareWrapPanel IsItemsHost="True"/>
</Expander>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Categories

Resources