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);

    精神共享,智慧共融!
  • 相关阅读:
    .NET Core 服务调用 RPC
    从Docker 到 Kubernatetes 的跃迁之路
    同步异步-多线程梳理
    Net的微服务选型之路
    Visual Studio 2019安装SSIS
    HL7协议的基本语法
    vue学习笔记
    开发常用的部分sql语句总结
    VSPD虚拟串口来调试通信接口程序
    SSRS报表工具之合并行数据
  • 原文地址:https://www.cnblogs.com/DataBase-123/p/5907911.html
Copyright © 2011-2022 走看看