1

我在工具箱上添加工具箱项,它嵌入到 xaml 上的扩展器控件中。我如何在这些工具箱项之间进行迭代和遍历?我的假设是工具箱是工具箱的孩子还是我应该通过扩展器?

谢谢。

XAML 在这里:

    <StackPanel Grid.Column="0" Margin="0,0,5,0">                    
            <Label Name="lblFind">Find:</Label>
        <StackPanel Name="spFind" Orientation="Horizontal">
        <TextBox Name="txtFind" Width="200" Height="22" ></TextBox>

        <Button Content="Go" Width="60" Height="30"
                IsEnabled="{Binding ElementName=txtFind, Path=Text.Length, Mode=OneWay}" Click="Button_Click" />
        </StackPanel>
        **<Expander x:Name="expander_Controls" Header="Controls" Content="{StaticResource myRESOURCE}" IsExpanded="True" />**


    </StackPanel>
        </ScrollViewer>
    <!-- GridSplitter -->
    <GridSplitter Focusable="False" Width="2" Background="LightGray"
            VerticalAlignment="Stretch" HorizontalAlignment="Right"/>


    <StackPanel Grid.Column="5" Background="AliceBlue">
        <ListView Background="LightGray" Opacity="1" ForceCursor="False" x:Name="myTree" x:FieldModifier="public">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Nodes" Width="80"/>
                 </GridView>
            </ListView.View>
        </ListView>
    </StackPanel>

解决方案:

var myList = this.FindResource("MyResource") as Toolbox;

for (int i = 0; i <= (myList .Items.Count - 1); i++)
{
    Object objResult = myList.GetType().GetProperty("Tag").GetValue(myList.Items[i], null);
    MessageBox.Show(objList.ToString());
    }
4

0 回答 0