Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 在列表框中使用径向面板,抛出异常VisualTree单个元素_Wpf_Listbox_Panel_Itemspanel_Radial - Fatal编程技术网

Wpf 在列表框中使用径向面板,抛出异常VisualTree单个元素

Wpf 在列表框中使用径向面板,抛出异常VisualTree单个元素,wpf,listbox,panel,itemspanel,radial,Wpf,Listbox,Panel,Itemspanel,Radial,我有一个非常简单的径向面板,其中包含一些依赖属性,如: public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(CircularPanel), new PropertyMetadata(50.0, new PropertyChangedCallback(RadiusChanged))); private stat

我有一个非常简单的径向面板,其中包含一些依赖属性,如:

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(); }
问题是,每当我将此放射状面板指定为列表框的itemspanel时,都会出现一个异常:

ItemsPanelTemplate的VisualTree必须是单个元素。

以下是我在XAML中设置ItemsPanel的方式:

<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}" >

如果删除依赖项属性的PropertyChangedCallback函数,面板将工作,但由于我无法刷新面板,因此每当我更改绑定到列表框的集合时,所有项都将以相互重叠的方式绘制,而不是以循环的方式绘制。这是WPF。我在silverlight试过,没有问题

谢谢你的帮助。谢谢