Flutter學習筆記(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar

来源:https://www.cnblogs.com/upwgh/archive/2019/08/21/11386530.html
-Advertisement-
Play Games

如需轉載,請註明出處:Flutter學習筆記(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar FloatingActionButton FloatingActionButton FloatingA ...


如需轉載,請註明出處:Flutter學習筆記(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar

  • FloatingActionButton

FloatingActionButton對應一個圓形圖標按鈕,懸停在內容之上,以展示對應程式中的主要動作,所以非常醒目,類似於iOS系統里的小白點按鈕。

FloatingActionButton組件屬性及描述如下:

  1. child:child一般為icon,不推薦使用文字
  2. tooltip:按鈕提示文字
  3. foregroundColor:前景色
  4. backgroundColor:背景色
  5. elevation:未點擊時陰影值,預設6.0
  6. hignlightElevation:點擊時陰影值
  7. onPressed:點擊事件回調
  8. shape:定義按鈕的shape,設置shape時,預設的elevation將會失效,預設為CircleBorder
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new MaterialApp(
      title: 'FloatingButton Demo',
      debugShowCheckedModeBanner: false,
      home: new Scaffold(
        appBar: AppBar(
          title: new Text('FloatingButton Demo'),
        ),
        drawer: Drawer(
          child: ListView(
            children: <Widget>[
              UserAccountsDrawerHeader(
                  accountName: new Text('FloatingButton Demo'),
                  accountEmail: new Text('www.baidu.com'),
                  currentAccountPicture: new CircleAvatar(
                    backgroundImage: AssetImage('images/user.jpeg'),
                  ),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              )
            ],
          ),
        ),
        floatingActionButton: new Builder(builder: (BuildContext context){
          return new FloatingActionButton(
              child: Icon(Icons.album),
              foregroundColor: Colors.amberAccent,
              backgroundColor: Colors.deepPurple,
              elevation: 10.0,
              highlightElevation: 20.0,
              mini: false,
              onPressed: (){
                Scaffold.of(context).showSnackBar(new SnackBar(content: new Text('點擊了FloatingButton')));
              }
          );
        }),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      ),
    );
  }

}

 

 

  • PopupMenuButton

構造方法:

  const PopupMenuButton({
    Key key,
    @required this.itemBuilder,//item子項,可以為任意類型
    this.initialValue,//初始值
    this.onSelected,//選中其中一項時回調
    this.onCanceled,//點擊空白處,不選擇時回調
    this.tooltip,//提示
    this.elevation = 8.0,//陰影大小
    this.padding = const EdgeInsets.all(8.0),//padding
    this.child,
    this.icon,
    this.offset = Offset.zero,
  }) : assert(itemBuilder != null),
        assert(offset != null),
        assert(!(child != null && icon != null)), // fails if passed both parameters
        super(key: key);

 

demo示例:

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new MaterialApp(
      title: 'FloatingButton Demo',
      debugShowCheckedModeBanner: false,
      home: new Scaffold(
        body: new Center(
          child: _showPopupMenuButton(),
        ),
        appBar: AppBar(
          title: new Text('FloatingButton Demo'),
        ),
        drawer: Drawer(
          child: ListView(
            children: <Widget>[
              UserAccountsDrawerHeader(
                  accountName: new Text('FloatingButton Demo'),
                  accountEmail: new Text('www.baidu.com'),
                  currentAccountPicture: new CircleAvatar(
                    backgroundImage: AssetImage('images/user.jpeg'),
                  ),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              ),
              ListTile(
                title: new Text('我是主標題'),
                leading: Icon(Icons.add_circle_outline),
                subtitle: new Text('我是副標題'),
              )
            ],
          ),
        ),
        floatingActionButton: new Builder(builder: (BuildContext context){
          return new FloatingActionButton(
              child: Icon(Icons.album),
              foregroundColor: Colors.amberAccent,
              backgroundColor: Colors.deepPurple,
              elevation: 10.0,
              highlightElevation: 20.0,
              mini: false,
              onPressed: (){
              },
          );
        }),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      ),
    );
  }

  PopupMenuButton _showPopupMenuButton() {
    return PopupMenuButton(
      icon: Icon(Icons.menu),
        itemBuilder: (BuildContext context) => <PopupMenuEntry>[
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton1"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton2"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton3"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton4"),
            ),
          ),
        ]
    );
  }
}

 

效果截圖:

   

  • SimpleDialog

 

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'FloatingButton Demo',
      debugShowCheckedModeBanner: false,
      home: mHomePage(),
    );
  }
}

class mHomePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _mHomePage();
  }
}

class _mHomePage extends State {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      body: new Center(
        child: _showPopupMenuButton(),
      ),
      appBar: AppBar(
        title: new Text('FloatingButton Demo'),
      ),
      drawer: Drawer(
        child: ListView(
          children: <Widget>[
            UserAccountsDrawerHeader(
              accountName: new Text('FloatingButton Demo'),
              accountEmail: new Text('www.baidu.com'),
              currentAccountPicture: new CircleAvatar(
                backgroundImage: AssetImage('images/user.jpeg'),
              ),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            )
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        child: Icon(Icons.album),
        foregroundColor: Colors.amberAccent,
        backgroundColor: Colors.deepPurple,
        elevation: 10.0,
        highlightElevation: 20.0,
        mini: false,
        onPressed: (){
            _showSimpleDialog(context);
        },
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
    );
  }

  PopupMenuButton _showPopupMenuButton() {
    return PopupMenuButton(
        icon: Icon(Icons.menu),
        itemBuilder: (BuildContext context) => <PopupMenuEntry>[
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton1"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton2"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton3"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton4"),
            ),
          ),
        ]
    );
  }

  void _showSimpleDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (BuildContext context){
          return SimpleDialog(
            title: new Text('SimpleDialog Demo'),
            children: <Widget>[
              SimpleDialogOption(
                child: Text('選項1'),
              ),
              SimpleDialogOption(
                child: Text('選項2'),
                onPressed: (){
                  Navigator.pop(context);
                },
              ),
            ],
          );
        }
    );
  }
}

 

效果截圖:

  • AlertDialog

AlertDialog常用屬性:

  const AlertDialog({
    Key key,
    this.title,//對話框頂部提示文案
    this.titlePadding,
    this.titleTextStyle,//對話框頂部提示文案字體樣式
    this.content,//內容部分,對話框的提示內容,通常為文字
    this.contentPadding = const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0),
    this.contentTextStyle,//對話框提示內容的字體樣式
    this.actions,//對話框底部操作按鈕
    this.backgroundColor,//對話框背景色
    this.elevation,
    this.semanticLabel,
    this.shape,
  }) : assert(contentPadding != null),
       super(key: key);

 

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'FloatingButton Demo',
      debugShowCheckedModeBanner: false,
      home: mHomePage(),
    );
  }
}

class mHomePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _mHomePage();
  }
}

class _mHomePage extends State {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      body: new Center(
        child: _showPopupMenuButton(),
      ),
      appBar: AppBar(
        title: new Text('FloatingButton Demo'),
      ),
      drawer: Drawer(
        child: ListView(
          children: <Widget>[
            UserAccountsDrawerHeader(
              accountName: new Text('FloatingButton Demo'),
              accountEmail: new Text('www.baidu.com'),
              currentAccountPicture: new CircleAvatar(
                backgroundImage: AssetImage('images/user.jpeg'),
              ),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            )
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        child: Icon(Icons.album),
        foregroundColor: Colors.amberAccent,
        backgroundColor: Colors.deepPurple,
        elevation: 10.0,
        highlightElevation: 20.0,
        mini: false,
        onPressed: (){
//            _showSimpleDialog(context);
          _showAlertDialog(context);
        },
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
    );
  }

  PopupMenuButton _showPopupMenuButton() {
    return PopupMenuButton(
        icon: Icon(Icons.menu),
        itemBuilder: (BuildContext context) => <PopupMenuEntry>[
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton1"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton2"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton3"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton4"),
            ),
          ),
        ]
    );
  }

  void _showSimpleDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (BuildContext context){
          return SimpleDialog(
            title: new Text('SimpleDialog Demo'),
            children: <Widget>[
              SimpleDialogOption(
                child: Text('選項1'),
              ),
              SimpleDialogOption(
                child: Text('選項2'),
                onPressed: (){
                  Navigator.pop(context);
                },
              ),
            ],
          );
        }
    );
  }

  void _showAlertDialog(BuildContext context) {
    showDialog(
      context: context,
      builder: (BuildContext context){
        return AlertDialog(
          title: new Text('提示'),
          content: new Text('這是提示框的內容'),
          actions: <Widget>[
            FlatButton(onPressed: null, child: new Text('確定'),disabledTextColor: Colors.blueAccent,),
            FlatButton(onPressed: null, child: new Text('取消'),disabledColor: Colors.deepPurple,),
          ],
        );
      }
    );
  }
}

 

效果截圖:

  • SnackBar

SnackBar是一個輕量級消息提示組件,在屏幕的底部顯示,SnackBar常用屬性如下:

  const SnackBar({
    Key key,
    @required this.content,//提示內容
    this.backgroundColor,//背景色
    this.action,
    this.duration = _kSnackBarDisplayDuration,//提示時常
    this.animation,//彈出動畫
  }) : assert(content != null),
       assert(duration != null),
       super(key: key);

 

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'FloatingButton Demo',
      debugShowCheckedModeBanner: false,
      home: mHomePage(),
    );
  }
}

class mHomePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _mHomePage();
  }
}

class _mHomePage extends State {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      body: new Center(
        child: _showPopupMenuButton(),
      ),
      appBar: AppBar(
        title: new Text('FloatingButton Demo'),
        actions: <Widget>[
          IconButton(icon: Icon(Icons.search), onPressed: (){
            Scaffold.of(context).showSnackBar(new SnackBar(content: new Text('SnackBar')));
          })
        ],
      ),
      drawer: Drawer(
        child: ListView(
          children: <Widget>[
            UserAccountsDrawerHeader(
              accountName: new Text('FloatingButton Demo'),
              accountEmail: new Text('www.baidu.com'),
              currentAccountPicture: new CircleAvatar(
                backgroundImage: AssetImage('images/user.jpeg'),
              ),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            ),
            ListTile(
              title: new Text('我是主標題'),
              leading: Icon(Icons.add_circle_outline),
              subtitle: new Text('我是副標題'),
            )
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        child: Icon(Icons.album),
        foregroundColor: Colors.amberAccent,
        backgroundColor: Colors.deepPurple,
        elevation: 10.0,
        highlightElevation: 20.0,
        mini: false,
        onPressed: (){
//            _showSimpleDialog(context);
          _showAlertDialog(context);
        },
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
    );
  }

  PopupMenuButton _showPopupMenuButton() {
    return PopupMenuButton(
        icon: Icon(Icons.menu),
        itemBuilder: (BuildContext context) => <PopupMenuEntry>[
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton1"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton2"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton3"),
            ),
          ),
          const PopupMenuItem(
            child: ListTile(
              leading: Icon(Icons.add_circle_outline),
              title: Text("popupMenuButton4"),
            ),
          ),
        ]
    );
  }

  void _showSimpleDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (BuildContext context){
          return SimpleDialog(
            title: new Text('SimpleDialog Demo'),
            children: <Widget>[
              SimpleDialogOption(
                child: Text('選項1'),
              ),
              SimpleDialogOption(
                child: Text('選項2'),
                onPressed: (){
                  Navigator.pop(context);
                },
              ),
            ],
          );
        }
    );
  }

  void _showAlertDialog(BuildContext context) {
    showDialog(
      context: context,
      builder: (BuildContext context){
        return AlertDialog(
          title: new Text('提示'),
          content: new Text('這是提示框的內容'),
          actions: <Widget>[
            FlatButton(onPressed: null, child: new Text('確定'),disabledTextColor: Colors.blueAccent,),
            FlatButton(
              onPressed: (){
                Navigator.pop(context);
                Scaffold.of(context).showSnackBar(new SnackBar(content: new Text('SnackBar')));
              },
              child: new Text('取消'),disabledColor: Colors.deepPurple,),
          ],
          backgroundColor: Colors.amberAccent,
        );
      }
    );
  }
}

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 小馬哥博客:https://www.cnblogs.com/majj/p/9179218.html 一、創建用戶 1.root用戶(管理員)登錄,進入mysql資料庫 2.創建用戶 3.為用戶授權 4.用戶登錄 ...
  • 重啟RAC時發現32004,後來才發現DG已經不存在了standby_archive_dest還在生效中,而background_dump_dest和user_dump_dest並沒在pfile中出現,最後註釋了standby_archive_destOK了糾結了一段時間,遇到問題多嘗試一下是必要的 ...
  • 下載 https://dev.mysql.com/downloads/mysql/5.7.html#downloads 參考鏈接 https://blog.csdn.net/qq_41307443/article/details/79839558 https://blog.csdn.net/wu_j ...
  • 1.數字註入 2.字元串註入 3. #後邊全部為註釋,字元串拼裝後繞過密碼驗證。 4. 同樣繞過密碼驗證 ...
  • 1.sql註入是怎麼產生的 2.如何尋找sql註入漏洞 在地址欄輸入單雙引號造成sql執行異常(get) post請求,在標題後輸入單引號,造成sql執行異常。 ...
  • 1.什麼是sql註入 sql註入是一種將sql代碼添加到輸入參數中,傳遞到sql伺服器解析並執行的一種攻擊手法。 2.正常行為,比如拿到id獲取文章的內容(案例) 3. 在瀏覽器中人為加入參數 or 1=1(永遠為真);這就產生了意想之外的行為,人為的獲取了整張表的內容,達到了攻擊的目的。 輸入參數 ...
  • 轉自: http://www.maomao365.com/?p=9336 摘要: 下文講述mssql中時間戳和時間格式的轉換方法,如下所示: 實驗環境:sql server 2008 R2 時間戳簡介:時間戳是linux下一種表示時間的方式。 時間戳是從 從格林威治時間1970年01月01日00時0 ...
  • 在Windows伺服器上確認伺服器和mysql都是正常運行,但就是連接不上。搜了一下別人的解決方案, 參考這篇https://blog.csdn.net/langren697/article/details/38422055的說法,問題就出在動態連接數上。給出的解決方案是在註冊表自定義最大連接數: ...
一周排行
    -Advertisement-
    Play Games
  • 概述:在C#中,++i和i++都是自增運算符,其中++i先增加值再返回,而i++先返回值再增加。應用場景根據需求選擇,首碼適合先增後用,尾碼適合先用後增。詳細示例提供清晰的代碼演示這兩者的操作時機和實際應用。 在C#中,++i 和 i++ 都是自增運算符,但它們在操作上有細微的差異,主要體現在操作的 ...
  • 上次發佈了:Taurus.MVC 性能壓力測試(ap 壓測 和 linux 下wrk 壓測):.NET Core 版本,今天計劃準備壓測一下 .NET 版本,來測試並記錄一下 Taurus.MVC 框架在 .NET 版本的性能,以便後續持續優化改進。 為了方便對比,本文章的電腦環境和測試思路,儘量和... ...
  • .NET WebAPI作為一種構建RESTful服務的強大工具,為開發者提供了便捷的方式來定義、處理HTTP請求並返迴響應。在設計API介面時,正確地接收和解析客戶端發送的數據至關重要。.NET WebAPI提供了一系列特性,如[FromRoute]、[FromQuery]和[FromBody],用 ...
  • 原因:我之所以想做這個項目,是因為在之前查找關於C#/WPF相關資料時,我發現講解圖像濾鏡的資源非常稀缺。此外,我註意到許多現有的開源庫主要基於CPU進行圖像渲染。這種方式在處理大量圖像時,會導致CPU的渲染負擔過重。因此,我將在下文中介紹如何通過GPU渲染來有效實現圖像的各種濾鏡效果。 生成的效果 ...
  • 引言 上一章我們介紹了在xUnit單元測試中用xUnit.DependencyInject來使用依賴註入,上一章我們的Sample.Repository倉儲層有一個批量註入的介面沒有做單元測試,今天用這個示例來演示一下如何用Bogus創建模擬數據 ,和 EFCore 的種子數據生成 Bogus 的優 ...
  • 一、前言 在自己的項目中,涉及到實時心率曲線的繪製,項目上的曲線繪製,一般很難找到能直接用的第三方庫,而且有些還是定製化的功能,所以還是自己繪製比較方便。很多人一聽到自己畫就害怕,感覺很難,今天就分享一個完整的實時心率數據繪製心率曲線圖的例子;之前的博客也分享給DrawingVisual繪製曲線的方 ...
  • 如果你在自定義的 Main 方法中直接使用 App 類並啟動應用程式,但發現 App.xaml 中定義的資源沒有被正確載入,那麼問題可能在於如何正確配置 App.xaml 與你的 App 類的交互。 確保 App.xaml 文件中的 x:Class 屬性正確指向你的 App 類。這樣,當你創建 Ap ...
  • 一:背景 1. 講故事 上個月有個朋友在微信上找到我,說他們的軟體在客戶那邊隔幾天就要崩潰一次,一直都沒有找到原因,讓我幫忙看下怎麼回事,確實工控類的軟體環境複雜難搞,朋友手上有一個崩潰的dump,剛好丟給我來分析一下。 二:WinDbg分析 1. 程式為什麼會崩潰 windbg 有一個厲害之處在於 ...
  • 前言 .NET生態中有許多依賴註入容器。在大多數情況下,微軟提供的內置容器在易用性和性能方面都非常優秀。外加ASP.NET Core預設使用內置容器,使用很方便。 但是筆者在使用中一直有一個頭疼的問題:服務工廠無法提供請求的服務類型相關的信息。這在一般情況下並沒有影響,但是內置容器支持註冊開放泛型服 ...
  • 一、前言 在項目開發過程中,DataGrid是經常使用到的一個數據展示控制項,而通常表格的最後一列是作為操作列存在,比如會有編輯、刪除等功能按鈕。但WPF的原始DataGrid中,預設只支持固定左側列,這跟大家習慣性操作列放最後不符,今天就來介紹一種簡單的方式實現固定右側列。(這裡的實現方式參考的大佬 ...