views:

8

answers:

0

Hi Guys,

I have a very simple radial panel with a few dependency properties like so:

public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(CircularPanel), new PropertyMetadata(50.0, new PropertyChangedCallback(RadiusChanged)));

private static void RadiusChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ((CircularPanel)sender).Refresh(); }

The problem is that whenever I assign this radial panel as the itemspanel of a listbox I get an exception:

VisualTree of ItemsPanelTemplate must be a single element.

This is how I set the ItemsPanel in XAML:

<ItemsPanelTemplate x:Key="ItemsPanelTemplate2">
        <WpfApplication7:CircularPanel d:LayoutOverrides="Width, Height" AngleItem="{Binding Angle}" AnimationDuration="75" Radius="0" InitialAngle="90"/>
</ItemsPanelTemplate>

<ListBox ItemsPanel="{StaticResource ItemsPanelTemplate2}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}" ItemsSource="{Binding Hosts, Mode=OneWay}" >

If I remove the PropertyChangedCallback function of the dependency properties, the panel works but since I cant refresh the panel, whenever I change the collection bound to the listbox, all the items are drawn on top of each other rather than in a circular manner. This is in WPF. I've tried in silverlight and there is no problem there.

Appreciate Your Help. Thanks