zoukankan      html  css  js  c++  java
  • pack://application:,,,/


    FrameworkElementFactory gridFactory = new FrameworkElementFactory(typeof(Grid));

    gridFactory.SetValue(Grid.MarginProperty, new Thickness(5));
    //gridFactory.SetValue(Grid.RowProperty, row); // 设置Grid.Row
    //gridFactory.SetValue(Grid.ColumnProperty, col);

    ImageBrush b = new ImageBrush();
    b.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Content/Images/GameImg/" + game.GameCode + ".png", UriKind.RelativeOrAbsolute));
    b.Stretch = Stretch.Fill;

    gridFactory.SetValue(Grid.BackgroundProperty, b);

    Style style = new Style();
    style.TargetType = typeof(Button);
    Setter setter = new Setter();
    setter.Property = ContentControl.TemplateProperty;
    ControlTemplate temp = new ControlTemplate(typeof(Button));

    temp.VisualTree = gridFactory;
    setter.Value = temp;
    style.Setters.Add(setter);

    Button button = new Button();
    button.Content = game.GameName;
    button.Command = this.FindResource("PlayCmd") as RoutedCommand;
    button.CommandParameter = game.GameCode;

    //button.Margin = new Thickness(5);
    button.SetValue(Grid.RowProperty, row);
    button.SetValue(Grid.ColumnProperty, col);
    button.Style = style;
    this.rootGrid.Children.Add(button);

    精神共享,智慧共融!
  • 相关阅读:
    基于s5pv210的uboot总结
    QQ群笔记
    设计模式----适配器模式
    设计模式----桥接模式
    设计模式----建造者模式
    设计模式----原型模式
    设计模式----单例模式
    设计模式----工厂方法模式
    设计模式----设计原则
    JUnit单元测试--小试牛刀
  • 原文地址:https://www.cnblogs.com/DataBase-123/p/5907911.html
Copyright © 2011-2022 走看看