自定義資訊框 C Wpf

2021-07-10 03:57:37 字數 3552 閱讀 5491

還在用messagebox.show()?你out了,弄了個自定義 c# wpf messagebox,共享一下,沒寫技術文件,但我想不難弄明白。

using galasoft.mvvmlight.commandwpf;

using system;

using system.windows;

using system.windows.input;

using system.windows.media.imaging;

namespace mvvmdlg

private string title;

private string content;

private relaycommandclosecmd;

private relaycommand closecancelcmd;

private static dlg dlg;

private static dialog dlgview;

private visibility shownocancel = visibility.collapsed;

private visibility showcancel = visibility.collapsed;

private uri iconuri;

private static bool dlgresult = false;

private static bool? dlgcannullresult = null;

public bool btnokoryes }

public bool btnnoorcancel }

public string title }

public string content }

public icommand closecmd);}

return this.closecmd;}}

public icommand closecancelcmd);}

return this.closecancelcmd;}}

public visibility shownocancel }

public visibility showcancel }

private uri seticonuri(dlgicon type)

return result;

}public static bool show(string text, string title, dlgbtn btntype)

dlgview.datacontext = dlg;

dlgview.icon = bitmapframe.create(dlg.iconuri);

dlgview.showdialog();

dlg = null;

return dlgresult;

}public static bool show(string text, string title, string btncontent)

dlgview.datacontext = dlg;

dlgview.icon = bitmapframe.create(dlg.iconuri);

dlgview.showdialog();

dlg = null;

return dlgresult;

}public static bool show(string text, string title, string btncontent, dlgicon icontype)

dlgview.datacontext = dlg;

dlgview.icon = bitmapframe.create(dlg.iconuri);

dlgview.showdialog();

dlg = null;

return dlgresult;

}public static bool show(string text, string title, dlgbtn btntype, dlgicon icontype)

dlg.iconuri = dlg.seticonuri(icontype);

dlgview.datacontext = dlg;

dlgview.icon = bitmapframe.create(dlg.iconuri);

dlgview.showdialog();

dlg = null;

return dlgresult;

}public static bool? cannullshow(string text, string title)

public static bool? cannullshow(string text, string title, string btncontent)

public static bool? cannullshow(string text, string title, string btncontent, dlgicon icontype)

}public enum dlgbtn

public enum dlgicon

}

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", dlgbtn.ok);

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", "aa");

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", "aa|bb", dlgicon.error);

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", dlgbtn.ok, dlgicon.error);

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", dlgbtn.okcancel);

dlg.show("使用者名稱或密碼錯誤!", "錯誤提示", dlgbtn.okcancel, dlgicon.error);

dlg.cannullshow("使用者名稱或密碼錯誤!", "錯誤提示");

dlg.cannullshow("使用者名稱或密碼錯誤!", "錯誤提示", "aa|bb|cc");

自定義搜尋框

自定義搜尋框 1 自定義自定義的文字框必須在 void layoutsubviews中才能自定義 即子控制項必須在layoursubviews中設定,而searchbar可以直接設定 placeholder,外背景 2 storyboard隨意設定即可 3 純 字型顏色和大小無法設定,但是外邊框可以...

自定義彈框

1.警告框 設定乙個negativebutton builder.setnegativebutton 取消 new dialoginte ce.onclicklistener 設定乙個neutralbutton builder.setneutralbutton 忽略 new dialoginte c...

自定義資訊傳遞

現在有一系列資訊需要傳遞,處理成自定義的格式,然後接收後再進行解析 資訊自定義格式如下 actiontype update incno s2008053080034 branchkey 4 inclevel 3a inctype gambling stationkey 100 status clos...