Monday, August 27, 2012

How to stop paths appearing on a new line using an ItemsControl template

How to stop paths appearing on a new line using an ItemsControl template

I have some XAML that looks like this:

<ItemsControl ItemsSource="{Binding PathStrings}">     <ItemsControl.ItemTemplate>         <DataTemplate>             <Path Stroke="Red" Data="{Binding}" StrokeThickness="5" />         </DataTemplate>     </ItemsControl.ItemTemplate>     <ItemsControl.ItemsPanel>         <ItemsPanelTemplate>              <VirtualizingStackPanel />         </ItemsPanelTemplate>     </ItemsControl.ItemsPanel> </ItemsControl> 

I am binding a list of path data from a database. However, when this renders out, the paths appear to be on a new line (like they are encased in something else). I would really love to fix this.
Any suggestions?

This is with a stackpanel with Horizonal
This is with a stackpanel that is horizonal

This is with a vertical stackpanel

This is with a vertical stack panel


Hopefully this helps someone to help me? Thanks

Answers & Comments...

Answer: 1

It turns out that it is as simple as using a Canvas as the ItemsPanelTemplate. That simple.

by : Joehttp://stackoverflow.com/users/325752




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog