【发布时间】:2016-01-20 05:33:24
【问题描述】:
获得了一个带有 StackPanel 的 WPF 表单,其中包含带有 StackPanel 的扩展器。
<Expander Name="eSoftware" Header="5 Software">
<StackPanel Name="StSoftware" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,8,0">
<StackPanel Margin="0,10" Width="29">
<Image x:Name="img" Height="26" Source="Images/3453120.png" Stretch="Fill" Margin="0,0,0,0"/>
</StackPanel>
<StackPanel Margin="0,10">
<Label x:Name="lbl" Content="Label" Margin="0,0,0,0" />
</StackPanel>
</StackPanel>
</Expander>
我在对象列表中阅读了扩展器的内容。 现在我必须知道列表是否包含堆栈面板类型的对象。
List<Object> tmpList = new List<Object>();
tmpList = ReadChild((StackPanel)exp.Content) //gives out the content of an expander. In the Upper case it is 2 StackPanels
if(tmpList.Contains.typeof(StackPanel)=true) //that's wrong
{
//search for the Stackpanel with lables in it
}
【问题讨论】:
-
您可能想要比较而不是赋值:
tmpList.Contains.typeof(StackPanel)=true到tmpList.Contains.typeof(StackPanel)==true