image

MainWindow.xaml
 1: <Window x:Class="WpfDispatcherApp.MainWindow"
 2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4: xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5: xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6: xmlns:local="clr-namespace:WpfDispatcherApp"
 7: mc:Ignorable="d"
 8: Title="MainWindow" Height="137" Width="554">
 9: <UniformGrid Rows="3" Columns="2">
 10: <Label Content="Input a number:" Height="28" HorizontalAlignment="Center" Name="label1" VerticalAlignment="Center" />
 11: <TextBox Height="23" HorizontalAlignment="Center" Name="textBox1" VerticalAlignment="Center" Width="100" Text="1000000000"/>
 12:  
 13: <Label Content="Result:" Height="28" HorizontalAlignment="Center" Name="label2" VerticalAlignment="Center" />
 14: <TextBox Height="23" HorizontalAlignment="Center" Name="textBox2" VerticalAlignment="Center" Width="100"/>
 15: <Button Content="synchronization" Height="23" HorizontalAlignment="Center" Name="button1" VerticalAlignment="Center" Width="100" Click="button1_Click" />
 16: <Button Content="asynchronization" Height="23" HorizontalAlignment="Center" Name="button2" VerticalAlignment="Center" Width="100" Click="button2_Click" />
 17: </UniformGrid>
 18: </Window>

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
如果你想要直接修改ComboBox背景顏色為自訂義漸層顏色,你應該會跟我遇到一樣的狀況,怎麼改都沒有作用@@
 1: <ComboBox Background="Yellow">
 2: <ComboBox.Resources>
 3: <!-- color of ComboBoxItem -->
 4: <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="Yellow" />
 5: <!-- Mouse over color of ComboBoxItem -->
 6: <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red" />
 7: </ComboBox.Resources>
 8: <ComboBoxItem>One</ComboBoxItem>
 9: <ComboBoxItem>Two</ComboBoxItem>
 10: <ComboBoxItem>Three</ComboBoxItem>
 11: </ComboBox>

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

一上二下排列,基本上可以先定義兩列兩行,然後針對第一列(Grid.Row=0)特別定義跨兩行,也就是Grid.ColumnSpan=”2”第二列因為沒有跨行所以不用另外定義Grid.ColumnSpan
 1: <Grid>
 2: <Grid.RowDefinitions >
 3: <RowDefinition Height="100" />
 4: <RowDefinition />
 5: </Grid.RowDefinitions>
 6: <Grid.ColumnDefinitions >
 7: <ColumnDefinition Width="200" />
 8: <ColumnDefinition />
 9: </Grid.ColumnDefinitions>
 10:  
 11: <!--Panel-->
 12: <Border Grid.Row="0" Grid.Column="0" Background="Blue" Grid.ColumnSpan="2" />
 13: <!--<Border Grid.Row="0" Grid.Column="1" Background="LightSalmon" />-->
 14: <Border Grid.Row="1" Grid.Column="0" Background="Green" />
 15: <Border Grid.Row="1" Grid.Column="1" Background="Red" />
 16: </Grid>

me1237guy 發表在 痞客邦 留言(0) 人氣()

image
Markup Extensions and WPF XAML
新增一個類別 SaySomething.cs
定義兩個靜態屬性English和Chinese
 1: namespace WpfApp7
 2: {
 3: public class SaySomething
 4: {
 5: public static string English
 6: {
 7: get { return "Hello, how are you today?"; }
 8: }
 9: public static string Chinese
 10: {
 11: get { return "哈囉!今天好嗎?"; }
 12: }
 13: }
 14: }

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

加入參考 using System.Windows.Threading;

me1237guy 發表在 痞客邦 留言(0) 人氣()

1. WPF – MVVM (一)2. WPF – MVVM (二)3. WPF – MVVM (三)4. UWP 和 WPF 对比

me1237guy 發表在 痞客邦 留言(0) 人氣()

(1) 在 Windows Forms 中裝載 WPF 控制項
https://docs.microsoft.com/zh-tw/dotnet/framework/wpf/advanced/walkthrough-hosting-a-wpf-composite-control-in-windows-forms
(2) 反過來在 WPF 中裝載 Windows Forms 控制項
https://docs.microsoft.com/zh-tw/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf

me1237guy 發表在 痞客邦 留言(0) 人氣()

image

 1: <Window x:Class="WpfApp3.MainWindow"
 2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4: xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5: xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6: xmlns:local="clr-namespace:WpfApp3"
 7: mc:Ignorable="d"
 8: Title="MainWindow" Height="450" Width="800">
 9: <Grid>
 10: <Button Height="60"
 11: Width="200"
 12: Click="MyButton_Click"
 13: Content="點我"/>
 14:  
 15: </Grid>
 16: </Window>

me1237guy 發表在 痞客邦 留言(0) 人氣()

1
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。