zoukankan      html  css  js  c++  java
  • WP7备注(21)(ScrollViewer)

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <ScrollViewer HorizontalScrollBarVisibility="Auto">
    <StackPanel Name="stackPanel" />
    </ScrollViewer>
    </Grid>

    当横向数据过长时候,显示滚动条,没有过长,则不显示

    using System;
    using System.Collections.Generic;
    namespace PublicClasses
    {
    class ClassAndChildren
    {
    public ClassAndChildren(Type parent)
    {
    Type = parent;
    SubClasses = new List<ClassAndChildren>();
    }
    public Type Type { set; get; }
    public List<ClassAndChildren> SubClasses { set; get; }
    }
    }
    public partial class MainPage : PhoneApplicationPage
    {
    Brush accentBrush;
    public MainPage()
    {
    InitializeComponent();
    accentBrush = this.Resources["PhoneAccentBrush"] as Brush;
    // Get all assemblies
    List<Assembly> assemblies = new List<Assembly>();
    assemblies.Add(Assembly.Load("System.Windows"));
    assemblies.Add(Assembly.Load("Microsoft.Phone"));
    assemblies.Add(Assembly.Load("Microsoft.Phone.Controls"));
    assemblies.Add(Assembly.Load("Microsoft.Phone.Controls.Maps"));
    // Set root object (use DependencyObject for shorter list)
    Type typeRoot = typeof(object);
    // Assemble total list of public classes
    List<Type> classes = new List<Type>();
    classes.Add(typeRoot);
    foreach (Assembly assembly in assemblies)
    foreach (Type type in assembly.GetTypes())
    if (type.IsPublic && type.IsSubclassOf(typeRoot))
    classes.Add(type);
    // Sort those classes
    classes.Sort(TypeCompare);
    // Now put all those sorted classes into a tree structure
    ClassAndChildren rootClass = new ClassAndChildren(typeRoot);
    AddToTree(rootClass, classes);
    // Display the tree
    Display(rootClass, 0);
    }
    int TypeCompare(Type t1, Type t2)
    {
    return String.Compare(t1.Name, t2.Name);
    }
    // Recursive method
    void AddToTree(ClassAndChildren parentClass, List<Type> classes)
    {
    foreach (Type type in classes)
    {
    if (type.BaseType == parentClass.Type)
    {
    ClassAndChildren subClass = new ClassAndChildren(type);
    parentClass.SubClasses.Add(subClass);
    AddToTree(subClass, classes);
    }
    }
    }
    // Recursive method
    void Display(ClassAndChildren parentClass, int indent)
    {
    string str1 = String.Format("{0}{1}{2}{3}",
    new string(' ', indent * 4),
    parentClass.Type.Name,
    parentClass.Type.IsAbstract ? " (abstract)" :
    "",
    parentClass.Type.IsSealed ? " (sealed)" : "");
    string str2 = " " + parentClass.Type.Namespace;
    TextBlock txtblk = new TextBlock();
    txtblk.Inlines.Add(str1);
    txtblk.Inlines.Add(new Run
    {
    Text = str2,
    Foreground = accentBrush
    });
    stackPanel.Children.Add(txtblk);
    foreach (ClassAndChildren child in parentClass.SubClasses)
    Display(child, indent + 1);
    }
    }

    image

  • 相关阅读:
    BZOJ4039 : 集会
    BZOJ3655 : 神经错乱数
    World Finals 2017爆OJ记
    Petrozavodsk Summer-2016. Ural FU Dandelion Contest
    XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017)
    递归的逻辑(3)——递归与分治
    递归的逻辑(2)——特征方程和递归算法
    递归的逻辑(1)——递归关系模型
    整数的故事(4)——Karastuba算法
    整数的故事(3)——最小公倍数与哥德巴赫猜想
  • 原文地址:https://www.cnblogs.com/otomii/p/2032481.html
Copyright © 2011-2022 走看看