讓 按鈕(button)不能按:
WPF Disabled button's background
https://stackoverflow.com/questions/25406878/wpf-disabled-buttons-background

因為 IsEnabled="False" 顏色會和原本不一樣,所以採用IsHitTestVisible="False"。

修改StackPanel的border,讓他四個角落變圓弧
Set a border around a StackPanel.
https://stackoverflow.com/questions/2663048/set-a-border-around-a-stackpanel

解答:在StackPanel外面放DockPanel 和Border

Window style 整理:

WindowStyle="None"
ResizeMode="NoResize"
WindowState="Maximized"
WindowStartupLocation="CenterScreen"
WindowStyle="None"  -- >去掉邊框
ResizeMode="NoResize"  -- > 不能縮小放大視窗
WindowState="Maximized" -- >全螢幕
WindowStartupLocation="CenterScreen" 視窗在螢幕正中間

4 寫畫面的方法:

在MainWindow.xaml 放一個這個:

                <Frame x:Name="page_frame"
                       NavigationUIVisibility="Hidden">
                </Frame>

其他畫面都用page (頁面):

一 跳畫面的方法:

// 在 MainWindow取得MainWindow
MainWindow mainWindow = Window.GetWindow(this) as MainWindow;
// 用xname 取得frame :
Frame frame  = (Frame) mainWindow.FindName("page_frame");
// frame 用  Navigate
frame.Navigate(new AnotherPage()); 

二 跳畫面 帶值的方法:

MainWindow :
frame.Navigate(new AnotherPage($"{變數}")  );
其他page也一樣,可以在MainWindow 有個static的frame變數,然後
MainWindow.frame.Navigate(new AnotherPage($"{變數}") );
AnotherPage 裡放變數:
        public AnotherPage (String 變數)
            InitializeComponent();
            var 獲得變數了 = 變數;
How to pass values (parameters) between XAML pages?
https://stackoverflow.com/questions/12444816/how-to-pass-values-parameters-between-xaml-pages

三 知道現在在哪個畫面的方法:

在MainWindow的 frame 使用這個東西:
frame.Content.GetType()
就可以知道 當前 是在哪個page!

5 客製化 警示窗

參考這篇大大教學的程式改的:
WPF - own MessageBox (C#, project for download)
https://www.youtube.com/watch?v=-eQMJrhMyYU&ab_channel=LadyWinnie

方法就是用兩個專案 ,一個客製化視窗 ,一個主程式原本的視窗

ShortNotification 的  意思 是 通知 
MessageBox  的  意思 是消息框

裡面有4個檔案:

一 W_MessageBox :

消息框 的樣式 :
OK 樣式 : 顯示 OK按鈕
YES or No 樣式: 顯示 YES按鈕 和 No按鈕

二 MyMessageBox :

控制 W_MessageBox消息框樣式

三 W_ShortNotification :

通知 視窗 的樣式 。
裡面放了TextBox 。

程式的func有Window_Closing 跟 視窗關閉 事件(System.ComponentModel.CancelEventArgs) 有關。
CancelEventArgs 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.componentmodel.canceleventargs?view=netcore-3.1

程式的func有 Window_Loaded ,視窗載入事件(不確定)
RoutedEventArgs 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.windows.routedeventargs?view=netcore-3.1

W程式的func有Window_MouseDown , 視窗被滑鼠點擊事件?
MouseButtonEventArgs 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.windows.input.mousebuttoneventargs?view=netcore-3.1

四 MyShortNotification

控制 W_ShortNotification
有Show(string text) 方法 , 把 文字帶給視窗,顯示視窗
有 ShowDialog(string text) 方法, 把除了當今視窗(就是W_ShortNotification) 以外的視窗變模糊。

跟這個有關:
BlurEffect 類別
https://docs.microsoft.com/zh-tw/dotnet/api/system.windows.media.effects.blureffect?view=netcore-3.1

使目標材質模糊的點陣圖效果。

五 主視窗 帶值 到 新開的視窗?

就是讓 MessageBox 的 func 有參數

MessageBox.ShowYNDialog("參數");

新開的視窗 把值 帶回 主視窗?
像是 在 警告視窗 按了確認 , 回到主視窗 ,要知道-- > 確認 代表YES 代表TRUE,才能繼續程式!

方法就是: MessageBox 的 func 有 return 值 ,這樣就帶回來了 。

String returnValue = MessageBox.ShowYNDialog("參數");

returnValue 就是關掉新開的視窗後,回到MainWindow的值!

6 圖片顯示 不出來

Image not displaying in C# WPF
https://stackoverflow.com/questions/24049511/image-not-displaying-in-c-sharp-wpf

圖片右鍵 屬性, 改成這樣:

7 找child element

現在有一個DockPanel ,x:Name="myDockPanel" DockPanel 的 child是 4個StackPanel 。 x:Name分別是 x:Name="sp1"、x:Name="sp2"、x:Name="sp3"、x:Name="sp4" 要怎麼透過DockPanel , 取得 name是sp4 的 StackPanel ? How can I find WPF controls by name or type?
https://stackoverflow.com/questions/636383/how-can-i-find-wpf-controls-by-name-or-type
第一個解答

由於程式有點難,看不懂 , 只需要往下找一層child 。所以稍微修改
       public static T FindChild<T>(DependencyObject parent, string childName)
               where T : DependencyObject
            // Confirm parent and childName are valid. 
            if (parent == null) return null;
            T foundChild = null;
            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
            for (int i = 0; i < childrenCount; i++)
                Debug.WriteLine($"有幾個children?{childrenCount}");
                var child = VisualTreeHelper.GetChild(parent, i);
                // If the child is not of the request child type child
                //T childType = child as T;
                if (!string.IsNullOrEmpty(childName))
                    var frameworkElement = child as FrameworkElement;
                    Debug.WriteLine($"child的名字?{frameworkElement.Name}");
                    // If the child's name is set for search
                    //名字一樣,就代表找到child了
                    if (frameworkElement != null && frameworkElement.Name == childName)
                        // if the child's name is of the request name     
                        foundChild = (T)child; 
                        break;
            return foundChild;
//先用main window 的 findname 找到DockPanel
MainWindow mw = Window.GetWindow(this) as MainWindow;
DockPanel dockPanel = (DockPanel)mw.FindName("myDockPanel");
//child不能用findname ? 所以要自己寫上面那段程式?
StackPanel foundStackPanel = FindChild<StackPanel>(dockPanel, "sp4");