You can change your layout to use an ItemsControl. Here's a prototype (without your styling)...
<ItemsControl ItemsSource="{Binding MyCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" MaxWidth="450"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" MaxWidth="150">
<TextBlock Width="90" Text="{Binding CategoryName}" Margin="0,0,10,0"/>
<TextBlock Width="50" Text="{Binding CategoryCount}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
This items control uses a horizontal Wrap Panel so that your categories are wrapped across the surface and will start a new row when the allotted space is exhausted on the current row.
The item template has two bound text blocks which can be used to display your items. The control itself is bound to a collection of your category counts.
The container class would look like this...
public class CategoryCounts: INotifyPropertyChanged
{
private int _categoryCount;
public int CategoryCount
{
[DebuggerStepThrough]
get { return _categoryCount; }
[DebuggerStepThrough]
set
{
if (value != _categoryCount)
{
_categoryCount = value;
OnPropertyChanged("CategoryCount");
}
}
}
private string _categoryName;
public string CategoryName
{
[DebuggerStepThrough]
get { return _categoryName; }
[DebuggerStepThrough]
set
{
if (value != _categoryName)
{
_categoryName = value;
OnPropertyChanged("CategoryName");
}
}
}
}
Finally, the View Model would look something like this...
public class ViewModel:INotifyPropertyChanged
{
public ObservableCollection<CategoryCounts> MyCollection { get; set; }
public ViewModel()
{
MyCollection = new ObservableCollection<CategoryCounts>();
MyCollection.Add(new CategoryCounts{CategoryName = "some category", CategoryCount = 22});
}
#region INotifyPropertyChanged Implementation
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string name)
{
var handler = System.Threading.Interlocked.CompareExchange(ref PropertyChanged, null, null);
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
You can get almost the same results using a DataGrid or a ListView, but the 'wrapping' effect will be forfeit because grids use a 'record per row' extending in the vertical direction, laid out with proper column headers etc.