2011年4月26日

Styling Separators in WPF

最近利用 WPF 設計 UI 時,想把 Menu Separator 的 Template 改掉,以為是個很簡單的工作,卻花了不少時間。還好找到了下面的一篇文章,這跟常規的處理方式略為不同,真不知道 WPF 還有多少控制項,也有相同的問題。

[Reference]
Styling Separators in WPF

2011年4月19日

Dual Screen Application and WPF

使用 WPF 建立雙螢幕或多螢幕畫面,作法如下:
  1. 首先刪除 App.xaml 中的 StartupUri="MainWindows.xaml"的設定。
  2. 加入 System.Windows.Forms (for Screen) 與 System.Drawing (for Rectangle) 等參考。
  3. 在 App.xaml.cs 中加入下列的程式碼 (以雙螢幕為例)。

App.xaml.cs:
 
    public partial class App : System.Windows.Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow w1 = new MainWindow();
            MainWindow w2 = new MainWindow();

            Screen s1 = Screen.AllScreens[0];
            Screen s2 = Screen.AllScreens[1];

            Rectangle r1 = s1.WorkingArea;
            Rectangle r2 = s2.WorkingArea;

            w1.Top = r1.Top;
            w1.Left = r1.Left;

            w2.Top = r2.Top;
            w2.Left = r2.Left;

            w1.Show();
            w2.Show();

            w2.Owner = w1;
        }
    }

如果希望畫面在開啟時,都以全螢幕方式顯示,在屬性表設定是無效的,
必須等到 load 之後,才能指定。
MainWindow.xaml.cs:
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Maximized;
        }
    }

參考資料:
Dual Screen Application and WPF
Maximizing a WPF Window to second monitor

Deploying Vue & .NET with Google OAuth on GCP Cloud Run

Deploying Vue & .NET with Google OAuth on GCP Cloud Run Deploying Vue & .NET with Google OAuth on GCP Cloud Run...