WPF所有原生空間使用demo

WantRemake發表於2024-04-27
//前臺窗體
<Window x:Class="WpfTestDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfTestDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="800" Width="1200">

    <!--#region 佈局控制元件 -->
    <!--普通表格-->
    <!--<Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Border BorderThickness="1 1 1 1" BorderBrush="Red" Grid.Column="0" Grid.Row="0">
            <Button Content="學習內容3" Grid.Row="0" Grid.Column="0" Panel.ZIndex="3" Margin="20,40,60,80" Padding="20"></Button>
        </Border>
        <Border BorderThickness="0 1 1 1" BorderBrush="Red" Grid.Column="1" Grid.Row="0">
            <Button Content="學習內容3" Grid.Row="0" Grid.Column="1" Panel.ZIndex="3" Margin="20,40,60,80" Padding="20"></Button>
        </Border>
        <Border BorderThickness="1 0 1 1" BorderBrush="Red" Grid.Column="0" Grid.Row="1">
            <Button Content="學習內容3" Grid.Row="1" Grid.Column="0" Panel.ZIndex="3" Margin="20,40,60,80" Padding="20"></Button>
        </Border>
        <Border BorderThickness="0 0 1 1" BorderBrush="Red" Grid.Column="1" Grid.Row="1">
            <Button Content="學習內容3" Grid.Row="1" Grid.Column="1" Panel.ZIndex="3" Margin="20,40,60,80" Padding="20"></Button>
        </Border>

        -->
    <!--<Button Content="學習內容" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Panel.ZIndex="1" Margin="20,40,60,80" Padding="20"></Button>
        <Button Content="學習內容3" Grid.Row="0" Grid.Column="1" Panel.ZIndex="3" Grid.RowSpan="2" Margin="20,40,60,80" Padding="20"></Button>-->
    <!--
    </Grid>-->

    <!--自動填充表格-->
    <!--<UniformGrid FirstColumn="1" Rows="3" Columns="3">
        <Button Content="biaogeceshitiancgong" Margin="2"></Button>
        <Button Content="biaogeceshitiancgong2" Margin="2"></Button>
        <Button Content="biaogeceshitiancgong3" Margin="2"></Button>
        <Button Content="biaogeceshitiancgong4" Margin="2"></Button>
        <Button Content="biaogeceshitiancgong4" Margin="2"></Button>
    </UniformGrid>-->

    <!--水平或垂直重疊子元素-->
    <!--<Grid>
        <ScrollViewer>
            <StackPanel Orientation="Vertical">
                <Button Content="stackpenal Test1" HorizontalAlignment="Left" Margin="10" Height="50"></Button>
                <Button Content="stackpenal Test2" HorizontalAlignment="Center" Margin="10" Height="50"></Button>
                <Button Content="stackpenal Test3" Margin="10" HorizontalAlignment="Right" Height="50"></Button>
                <Button Content="stackpenal Test4" Margin="10" HorizontalAlignment="Stretch" Height="50"></Button>
                <Button Content="stackpenal Test5" Margin="10" Height="50"></Button>
            </StackPanel>
        </ScrollViewer>
    </Grid>-->

    <!--瀑布流佈局-->
    <!--<WrapPanel ItemWidth="200" ItemHeight="80" Orientation="Vertical">
        <Button Content="wrappanel1 Test1" Margin="0"></Button>
        <Button Content="wrappanel2 Test2" Margin="0"></Button>
        <Button Content="wrappanel3 Test3" Margin="0"></Button>
        <Button Content="wrappanel4 Test4" Margin="0"></Button>
        <Button Content="wrappanel5 Test5" Margin="0"></Button>
    </WrapPanel>-->

    <!--停靠佈局-->
    <!--<DockPanel LastChildFill="False">
        <Button Content="dockpannel1 Test1" Margin="0" DockPanel.Dock="Top"></Button>
        <Button Content="dockpannel2 Test2" Margin="0" DockPanel.Dock="Left"></Button>
        <Button Content="dockpannel3 Test3" Margin="0" DockPanel.Dock="Right"></Button>
        <Button Content="dockpannel4 Test4" Margin="0" DockPanel.Dock="Bottom"></Button>
        <Button Content="dockpannel5 Test5" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
        <Button Content="dockpannel6 Test6" Margin="0"></Button>
    </DockPanel>-->


    <!--絕對佈局-->
    <!--<Canvas>
        <Button Content="dockpannel1" Margin="0" Canvas.Top="100"></Button>
        <Button Content="dockpannel2" Margin="0" Canvas.Right="100"></Button>
        <Button Content="dockpannel3" Margin="0" Canvas.Bottom="100"></Button>
        <Button Content="dockpannel4" Margin="0" Canvas.Left="100"></Button>
    </Canvas>-->

    <!--邊框佈局 Border-->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Border Background="LightBlue" Width="100" Height="50" Margin="5">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="border1"></TextBlock>
        </Border>
        <Border Background="LightCoral" Width="100" Height="50" CornerRadius="10" Margin="5">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center"  Text="border1"></TextBlock>
        </Border>

        <Border Background="LightGoldenrodYellow" Width="100" Height="100" CornerRadius="10 20 30 50" Margin="5">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center"  Text="border1"></TextBlock>
        </Border>
    </StackPanel>-->


    <!--佈局demo-->
    <!--<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>     -->
    <!--佔滿剩餘空間-->
    <!--
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        -->
    <!--TOP-->
    <!--
        <DockPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Background="#126A74" Height="60">
            <TextBlock Text="WPF佈局教程" Foreground="White" Margin="15,15" FontSize="20"/>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Border Height="35" Margin="10" BorderThickness="1" BorderBrush="#CA5100" Background="#CA5100" CornerRadius="7">
                    <TextBlock Text="退出系統" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0" />
                </Border>
            </StackPanel>
        </DockPanel>
        -->
    <!--LEFT-->
    <!--
        <StackPanel Grid.Row="1" Grid.Column="0" Width="350">
            <Border Height="250" Margin="10" Padding="5" Background="#439D84">
                <TextBlock Text="引數區域" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="16"/>
            </Border>
            <Border Height="250" Margin="10" Padding="5" Background="#9CDC7B">
                <TextBlock Text="引數區域" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="16"/>
            </Border>
            <Border Height="110" Margin="10" Padding="5" Background="#E97752">
                <TextBlock Text="引數區域" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="16"/>
            </Border>
        </StackPanel>
        
        -->
    <!--RIGHT-->
    <!--
        <Grid Grid.Row="1" Grid.Column="1">
            <Border Margin="10" Padding="5" BorderThickness="1" BorderBrush="#F7BD93" CornerRadius="5" Background="#FDD2B2">
                <TextBlock Text="主題區域" Margin="5"/>
            </Border>
            <Border Width="150" Height="150" Padding="5" BorderThickness="1" BorderBrush="Gray" Background="Red" CornerRadius="75">
                <TextBlock Text="開始執行" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="20"/>
            </Border>
        </Grid>
        
        -->
    <!--BOTTOM-->
    <!--
        <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Background="#CA5100">
            <TextBlock Text="版本號 1.2.3.4 版權所有:JackChen" FontSize="14" Foreground="White" Margin="3" HorizontalAlignment="Center"/>
        </Grid>
    </Grid>-->

    <!--分割控制元件-->
    <!--<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0" Background="LightBlue">
            <TextBlock TextWrapping="Wrap" Padding="10" LineHeight="20">
                您好,我是來自江西的JackieChen,歡迎來到美麗的文化之邦,江西,我們就是最強的,你可以在百度,谷歌,搜狗等各個地方都可以看到我們,這是完全ok的。
            </TextBlock>
        </Border>
        <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Center" ShowsPreview="True"/>
        <Border Grid.Column="2" Background="LightCoral">
            <TextBlock TextWrapping="Wrap" Padding="10" LineHeight="20">
                您好,我是來自江西的JackieChen2號,歡迎來到美麗的文化之邦,江西,我們就是最強的,你可以在百度,谷歌,搜狗等各個地方都可以看到我們,這是完全ok的。
            </TextBlock>
        </Border>
    </Grid>-->
    <!--#endregion-->

    <!--#region 模板 -->
    <!--<Grid>
        <Control Background="Red" FontSize="30" Width="400" Height="400" Foreground="Gray">
            <Control.Template>
                <ControlTemplate TargetType="Control">
                    <Border Width="300" Height="300" Background="Green" CornerRadius="90">
                        <TextBlock Background="{TemplateBinding Background}" Foreground="Gray"  HorizontalAlignment="Center" VerticalAlignment="Center" Text="WPF初始化學習"/>
                    </Border>
                </ControlTemplate>
            </Control.Template>
        </Control>
    </Grid>-->

    <!--ContentControl  內容模板-->
    <!--<Grid>
        <ContentControl FontSize="50" Foreground="Red">
            <ContentControl.ContentTemplate>
                <DataTemplate>
                    <Border HorizontalAlignment="Center" Background="Red" CornerRadius="10" VerticalAlignment="Center">
                        <TextBlock Text="{Binding}" Foreground="White" Padding="10"></TextBlock>
                    </Border>
                </DataTemplate>
            </ContentControl.ContentTemplate>

            這是我自己的測試程式,內容繫結
        </ContentControl>
    </Grid>-->
    <!--#endregion-->

    <!--#region Button所有型別 -->
    <!--<Grid>-->
    <!--<Button Click="Button_Click" Width="200" Height="80">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock Text="But" Grid.Column="0" Foreground="Red" FontSize="28"/>
                <TextBlock Text="ton" Grid.Column="1" Foreground="Green" FontSize="38"/>
            </Grid>
        </Button>-->

    <!--ToggleButton-->
    <!--<ToggleButton Content="toggleClick" Width="300" Height="100" FontSize="30" Click="ToggleButton_Click"/>-->
    <!--<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
            <ToggleButton Click="ToggleButton_Click">
                <Border Width="100" Height="100" CornerRadius="50" Background="Red">
                    <TextBlock FontSize="20" Text="Toggle" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </ToggleButton>
        </StackPanel>-->

    <!--CheckBox-->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Text="今晚吃什麼" />
            <CheckBox Content="豬肚雞" Name="ck1"/>
            <CheckBox Content="土豆燉牛肉" Name="ck2"/>
            <CheckBox Content="小炒雞" Name="ck3"/>
            <CheckBox Content="紅燒魚" Name="ck4"/>
            <Button Content="檢視選單" Margin="10,0" Click="Button_Click_1"/>
        </StackPanel>-->

    <!--RadioButton-->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Text="今晚吃什麼" />
            <RadioButton Content="豬肚雞" Name="ck1" GroupName="d" />
            <RadioButton Content="土豆燉牛肉" Name="ck2" GroupName="d"/>
            <RadioButton Content="小炒雞" Name="ck3" GroupName="x"/>
            <RadioButton Content="紅燒魚" Name="ck4" IsChecked="True" GroupName="x"/>
            <Button Content="檢視選單" Margin="10,0" Click="Button_Click_1"/>
        </StackPanel>-->

    <!--RepeatButton-->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Text="我要去刷牙" Margin="10,0" />
            <RepeatButton Content="擠牙膏" Click="RepeatButton_Click" Delay="1000" Interval="500" />
        </StackPanel>-->
    <!--</Grid>-->
    <!--#endregion-->

    <!--#region 文字顯示 label和textblock  label更強大,需要消耗更多資源,只顯示一段文字建議用textblock-->
    <!--<Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Label Content="label學習" Width="200" FontSize="20" Background="LightGreen" Foreground="Red"/>
            <Label>
                <StackPanel>
                    <TextBlock Text="你幹啥呢" Margin="5" Foreground="LightCoral"/>
                    <TextBlock Text="問你話呢" Margin="5"/>
                    <Label Content="沒啥,逗你玩呢" Background="LightBlue"/>
                </StackPanel>
            </Label>
            <Label FontSize="30">
                <WrapPanel>
                    <TextBlock Text="粗體文字" FontWeight="Bold"/>
                    <TextBlock Text="斜體" FontStyle="Italic"/>
                    <TextBlock>
                        <Run Text="這是1" Foreground="Red"/>
                        <Run Text="這是2" Foreground="Aquamarine" />
                        <Run Text="這是3" Foreground="Bisque"/>
                    </TextBlock>
                    <ScrollViewer Width="100" Height="100">
                        <TextBlock TextWrapping="Wrap" Text="這是一段很長很長的話,但是具體有多長,我也不知道,反正就是很長很長,長的離譜的長" FontStyle="Italic"/>
                    </ScrollViewer>
                </WrapPanel>
            </Label>
            <TextBlock Name="textBlock" Width="320" Height="100" FontSize="15" FontWeight="Black" FontStretch="Condensed" Foreground="White" Background="Teal"  TextAlignment="Center"
                       TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Margin="10" Padding="5" HorizontalAlignment="Center" VerticalAlignment="Center" LineHeight="30">
                <Run Foreground="Yellow" TextDecorations="Underline" Text="滾滾長江東逝水"/>
                <Run Foreground="Red" TextDecorations="OverLine" FontStyle="Italic" Text="浪花淘盡英雄"/>
                <Run Foreground="DarkSeaGreen" TextDecorations="Baseline" FontStyle="Oblique" Text="是非成敗整合塊。青山依舊在,幾度夕陽紅,您說呢?"/>
            </TextBlock>
        </StackPanel>
    </Grid>-->
    <!--#endregion-->

    <!--#region RichTextBox富文字框 -->
    <!--<StackPanel>
        <RichTextBox Name="_richTextBox" Margin="10,5" Padding="5" Height="270">
            <FlowDocument>
                <Paragraph TextAlignment="Center">讓你看看這個強大的功能</Paragraph>
                <Paragraph >還不錯把</Paragraph>
                <Paragraph >怎麼樣</Paragraph>
                <List MarkerOffset="25" MarkerStyle="Decimal" StartIndex="1">
                    <ListItem><Paragraph>第一段</Paragraph></ListItem>
                    <ListItem><Paragraph>第二段</Paragraph></ListItem>
                    <ListItem><Paragraph>第三段</Paragraph></ListItem>
                </List>
            </FlowDocument>
        </RichTextBox>
        <Button FontSize="30" Click="Button_Click_2" Content="確定"/>
    </StackPanel>-->
    <!--#endregion-->

    <!--#region 提示工具依賴於其他控制元件,相當於滑鼠懸浮事件 -->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button Content="確定" Width="100" Height="30" ToolTip="小小的花園裡"/>
        <Button Content="進入" Width="100" Height="30" Margin="5">
            <Button.ToolTip>
                <StackPanel>
                    <TextBlock Text="VIP教程" FontWeight="Bold"/>
                    <TextBlock Text="點選進入"/>
                    <Border BorderThickness="0,1,0,0" BorderBrush="Red" Margin="4">
                        <TextBlock Text="開啟新房"/>
                    </Border>
                </StackPanel>
            </Button.ToolTip>
        </Button>
    </StackPanel>-->
    <!--#endregion-->

    <!--#region 彈出視窗 -->
    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <CheckBox Name="_checkBox" Content="是否開啟Popup" ToolTip="這是一個提示視窗"/>
        <Popup Name="_popup" IsOpen="{Binding ElementName=_checkBox,Path=IsChecked}" PlacementTarget="{Binding ElementName=_checkBox}" StaysOpen="True">
            <Border BorderBrush="White" BorderThickness="1" Background="LightBlue">
                <StackPanel>
                    <TextBlock Text="VIP教程" FontWeight="Bold"/>
                    <TextBlock Text="點選進入"/>
                    <Border BorderThickness="0,1,0,0" BorderBrush="Red" Margin="4"/>
                    <TextBlock Text="開啟新房"/>
                </StackPanel>
            </Border>
        </Popup>
    </StackPanel>-->
    <!--#endregion-->

    <!--圖片-->
    <!--<Grid>
        <StackPanel>
            <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
            <Image Source="pack://application:,,,/image/wyz.jpeg" Stretch="Fill" StretchDirection="Both" Height="200" />
        </StackPanel>
    </Grid>-->

    <!--GroupBox-->
    <!--<GroupBox>
        <WrapPanel Orientation="Horizontal">
            <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
            </Border>
            <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
            </Border>
            <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
            </Border>
        </WrapPanel>
    </GroupBox>-->

    <!--<GroupBox>
        <ScrollViewer HorizontalScrollBarVisibility="Visible">-->
    <!--VerticalScrollBarVisibility="Visible"-->
    <!--
            <StackPanel Orientation="Horizontal">-->
    <!--Vertical-->
    <!--
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Height="200" />
                </Border>
            </StackPanel>
        </ScrollViewer>
    </GroupBox>-->

    <!--Slider-->
    <!--<Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Canvas>
            <StackPanel Orientation="Horizontal" Grid.Row="0" Name="stackpanel">
                <Border BorderBrush="LightBlue" BorderThickness="1" CornerRadius="5" Margin="5">
                    <Image Source="/image/wyz.jpeg" Stretch="Uniform" StretchDirection="Both" Width="{Binding ElementName=slider,Path=Value}" Height="{Binding ElementName=slider,Path=Value}" />
                </Border>
            </StackPanel>
        </Canvas>
        <Slider Name="slider" Grid.Row="1" Minimum="50" Maximum="500" Value="50" VerticalAlignment="Bottom" Panel.ZIndex="100">
        </Slider>
        <TextBlock Grid.Row="1">
            <Run Text="width:"/>
            <Run Text="{Binding ElementName=slider,Path=Value}"/>
            <Run Text="Height:"/>
            <Run Text="{Binding ElementName=slider,Path=Value}"/>
        </TextBlock>
    </Grid>-->

    <!--ProgressBar-->
    <!--<Grid>
        <ProgressBar Name="progressBar" IsIndeterminate="False" Value="50" Minimum="0" Maximum="100" Orientation="Horizontal" Height="10" Margin="15"/>
        <TextBlock Name="textBlock" Text="50%" HorizontalAlignment="Center" Margin="1,150,0,0"/>
    </Grid>-->

    <!--Calendar日曆控制元件-->
    <!--<StackPanel>
        <Calendar Name="calendar" SelectionMode="MultipleRange" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,15" DisplayDateStart="2020/1/1" DisplayDateEnd="2024/1/1"/>
        <Button HorizontalAlignment="Center" Content="選擇" Click="Button_Click_3"/>
    </StackPanel>-->

    <!--DatePicker日期時間事件-->
    <!--<StackPanel HorizontalAlignment="Center" Margin="10">
        <StackPanel Orientation="Horizontal" Margin="10">
            <TextBlock Text="開始日期" VerticalAlignment="Center"/>
            <DatePicker Name="datepickerstrat" HorizontalAlignment="Center" Margin="10,0"/>
        </StackPanel>

        <StackPanel Orientation="Horizontal" Margin="10">
            <TextBlock Text="結束日期" VerticalAlignment="Center"/>
            <DatePicker Name="datepickerend" HorizontalAlignment="Center" Margin="10,0"/>
        </StackPanel>

        <Button HorizontalAlignment="Center" Content="選擇" Click="Button_Click_4"/>
    </StackPanel>-->

    <!--Expander展開-->
    <!--<StackPanel>
        <TextBlock Text="Expander用法"/>
        <Expander ExpandDirection="Down" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
            <Expander.Header>
                <Label Content="Expander用法"/>
            </Expander.Header>
            <Grid Background="LightBlue">
                <TextBlock TextWrapping="Wrap" Padding="10">
                    這是Expender的基礎用法,至於是怎麼用的,你看看例項就知道了,如果你還是不知道的話,那麼也許示例已經幫不了你了,我覺得你還是另尋高就吧,畢竟我已經幫不了你了,如果你覺得我還是能幫你那你就再看看示例吧,真的,我不騙你,我能幫你的只有這麼多了
                </TextBlock>
            </Grid>
        </Expander>

        <Expander ExpandDirection="Left" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
            <Expander.Header>
                <Label Content="Expander用法"/>
            </Expander.Header>
            <Grid Background="LightBlue">
                <TextBlock TextWrapping="Wrap" Padding="10">
                    這是Expender的基礎用法,至於是怎麼用的,你看看例項就知道了,如果你還是不知道的話,那麼也許示例已經幫不了你了,我覺得你還是另尋高就吧,畢竟我已經幫不了你了,如果你覺得我還是能幫你那你就再看看示例吧,真的,我不騙你,我能幫你的只有這麼多了
                </TextBlock>
            </Grid>
        </Expander>

        <Expander ExpandDirection="Right" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
            <Expander.Header>
                <Label Content="Expander用法"/>
            </Expander.Header>
            <Grid Background="LightBlue">
                <TextBlock TextWrapping="Wrap" Padding="10">
                    這是Expender的基礎用法,至於是怎麼用的,你看看例項就知道了,如果你還是不知道的話,那麼也許示例已經幫不了你了,我覺得你還是另尋高就吧,畢竟我已經幫不了你了,如果你覺得我還是能幫你那你就再看看示例吧,真的,我不騙你,我能幫你的只有這麼多了
                </TextBlock>
            </Grid>
        </Expander>

        <Expander ExpandDirection="Up" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
            <Expander.Header>
                <Label Content="Expander用法"/>
            </Expander.Header>
            <Grid Background="LightBlue">
                <TextBlock TextWrapping="Wrap" Padding="10">
                    這是Expender的基礎用法,至於是怎麼用的,你看看例項就知道了,如果你還是不知道的話,那麼也許示例已經幫不了你了,我覺得你還是另尋高就吧,畢竟我已經幫不了你了,如果你覺得我還是能幫你那你就再看看示例吧,真的,我不騙你,我能幫你的只有這麼多了
                </TextBlock>
            </Grid>
        </Expander>
    </StackPanel>-->

    <!--MediaElement影片播放,目前有聲音不出畫面,可能是解碼器的問題-->
    <!--<Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <MediaElement Name="_MdiuElement" LoadedBehavior="Manual"/>
        <Border Name="_Border" Background="Black">
            <TextBlock Name="_TextBlock" Text="MediaElement | 媒體播放器" Foreground="LightCoral" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Border>
        <StackPanel Orientation="Horizontal" Grid.Row="1">
            <Button Content="開啟" Width="60" Height="25" Margin="5" Click="OpenMeida"/>
            <Button Content="播放" Width="60" Height="25" Margin="5" Click="PlayMeida"/>
            <Button Content="停止" Width="60" Height="25" Margin="5" Click="StopMeida"/>
            <Button Content="後退" Width="60" Height="25" Margin="5" Click="BackMeida"/>
            <Button Content="前進" Width="60" Height="25" Margin="5" Click="ForwardMeida"/>
            <TextBlock Text="音量" Width="60" Height="25" Margin="5" VerticalAlignment="Center"/>
            <Slider Name="_Slider" Minimum="0" Maximum="100" Value="50" Width="120" VerticalAlignment="Center" HorizontalAlignment="Center" ValueChanged="Slider_ValueChange"/>
        </StackPanel>
        <Grid Grid.Row="2">
            <ProgressBar Name="_ProgressBar" Height="10" Margin="5"/>
        </Grid>
    </Grid>-->

    <!--ItemsControl控制元件集合皮膚-->
    <!--<Grid>
        <ItemsControl Name="_ItemControl" Background="LightBlue">-->
    <!--ItemsSource=" " 資料繫結-->
    <!--
            <Button Content="Content" Margin="15,5" Click="Button_Click_ItemControl"/>
            <Border Height="30" Background="LightCoral" Margin="5"/>
            <TextBlock Text="TextBlock" Background="LightCyan"/>
        </ItemsControl>
    </Grid>-->

    <!--ListBox-->
    <!--<Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        
        <ListBox Name="listBox" Margin="5" DisplayMemberPath="Name" SelectedValuePath="Age" />
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
            <Button Content="檢視結果" Click="Button_Click_Result"/>
            <TextBlock Name="_TextBlock"/>
        </StackPanel>
    </Grid>-->

    <!--ListView-->
    <!--<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>

        <ListView Name="listBox" Margin="5" SelectionChanged="listBox_SelectionChanged">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="姓名" DisplayMemberBinding="{Binding Name}"/>
                    <GridViewColumn Header="年齡" DisplayMemberBinding="{Binding Age}"/>
                    <GridViewColumn Header="地址" DisplayMemberBinding="{Binding Address}"/>
                </GridView>
            </ListView.View>
        </ListView>

        <StackPanel Margin="5" Grid.Column="1">
            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="姓名:" />
                <TextBlock Name="_name" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="年齡:" />
                <TextBlock Name="_age" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="地址:" />
                <TextBlock Name="_address" />
            </StackPanel>
        </StackPanel>
    </Grid>-->

    <!--ComboBox-->
    <!--<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>

        <StackPanel>
            <ComboBox Name="_comBox1" Margin="20" Height="30" IsEditable="True" TextBoxBase.TextChanged="_comBox1_TextChanged" />
            <ComboBox Name="_comBox2" Margin="20" Height="30" StaysOpenOnEdit="True" SelectionChanged="_comBox1_SelectionChanged" DisplayMemberPath="Name" />
        </StackPanel>

        <StackPanel Margin="5" Grid.Column="1">
            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="姓名:" />
                <TextBlock Name="_name" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="年齡:" />
                <TextBlock Name="_age" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="地址:" />
                <TextBlock Name="_address" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Text="電話:" />
                <TextBlock Name="_phone" />
            </StackPanel>
        </StackPanel>
    </Grid>-->

    <!--<Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>

        <TabControl Name="tabCon" SelectionChanged="tabCon_SelectionChanged">
            <TabItem Header="首頁">
                <Border Background="LightBlue">
                    <TextBlock Text="首頁介面" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </TabItem>
            <TabItem Header="內容中心">
                <Border Background="LightCoral">
                    <TextBlock Text="內容中心介面" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </TabItem>
            <TabItem Header="我的資訊">
                <Border Background="LightCyan">
                    <TextBlock Text="我的資訊介面" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </TabItem>
        </TabControl>

        <TextBlock Grid.Row="1" Name="showCon"/>
    </Grid>-->

    <!--TreeView 樹形圖-->
    <!--<Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal">
            <TextBlock Text="根目錄" Width="auto" Margin="10"/>
            <TextBox Width="850" Name="_TetxBox"/>
            <Button Content="路徑選擇.." Click="Button_Click_SelectRoot" Margin="10"/>
        </StackPanel>

        <TreeView Name="_TreeView" Grid.Row="1" BorderThickness="1" BorderBrush="LightBlue" Margin="10" SelectedItemChanged="TreeView_SelectedItemChanged"/>
    </Grid>-->

    <!--Menu選單欄-->
    <!--<Grid>
        <StackPanel>
            <Menu Name="_Menu">
                <MenuItem Header="檔案">
                    <MenuItem Header="新建"/>
                    <MenuItem Header="開啟">
                        <MenuItem.Icon>
                            <Image Source="/image/wyz.jpeg"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
            </Menu>
            
            <Menu Name="_Menu2">
                <Menu.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                        <TextBlock Text="{Binding Name}"/>
                    </HierarchicalDataTemplate>
                </Menu.ItemTemplate>
            </Menu>
        </StackPanel>
    </Grid>-->

    <!--ContextMenu 右鍵選單欄-->
    <!--<Grid Margin="5">
        <Border Background="LightBlue" Width="200" Height="100" CornerRadius="30" PreviewMouseUp="Border_PreviewMouseUp">   --><!--單機任意按鍵--><!--
            <Border.ContextMenu>
                <ContextMenu Name="_contentMenu" StaysOpen="True" HorizontalOffset="-100" VerticalOffset="-100">
                    <MenuItem Header="複製" Click="MenuItem_Click"/>
                    <MenuItem Header="貼上" Command="{Binding MyCommand}"/>
                    <MenuItem Header="刪除"/>
                    <MenuItem Header="剪貼"/>
                </ContextMenu>
            </Border.ContextMenu>
        </Border>
    </Grid>-->
</Window>

//後臺方法

public partial class MainWindow : Window
{
    private string file = string.Empty;
    public List<MenuModel> menuModels = new List<MenuModel>();


    public class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Address { get; set; }
    }

    public class MenuModel
    {
        public string Name { get; set; }
        public List<MenuModel> Children { get; set; } = new List<MenuModel>();
        public string View { get; set; }
    }

    public MainWindow()
    {
        InitializeComponent();

        //buttom
        //Task.Run(() => {
        //    Application.Current.Dispatcher.Invoke(() => {
        //        _buttom.Content = "Just do it";
        //        });
        //});

        //progressBar
        //Loaded += (s, e) =>
        //{
        //    Task.Factory.StartNew(() =>
        //    {
        //        for (int i = 0; i <= 100; i++)
        //        {
        //            Dispatcher.Invoke(() =>     //子執行緒修改了主執行緒的控制元件屬性不出錯
        //            {
        //                textBlock.Text = $"{i}%";
        //                progressBar.Value = i;
        //            });

        //            Task.Delay(25).Wait();
        //        }
        //    });
        //};

        //影片播放進度條繫結
        //DispatcherTimer dispatcherTimer = new DispatcherTimer();
        //dispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000);
        //dispatcherTimer.Tick += (s, e) =>
        //{
        //    _ProgressBar.Value = _MdiuElement.Position.TotalMilliseconds;
        //};
        //dispatcherTimer.Start();

        //listBox.Items.Add(new Person { Name = "張三", Age = 18, Address = "浙江" });
        //listBox.Items.Add(new Person { Name = "李四", Age = 19, Address = "湖南" });
        //listBox.Items.Add(new Person { Name = "王五", Age = 16, Address = "四川" });

        List<Person> peopleList = new List<Person>();
        peopleList.Add(new Person { Name = "張三", Age = 18, Address = "浙江" });
        peopleList.Add(new Person { Name = "李四", Age = 19, Address = "湖南" });
        peopleList.Add(new Person { Name = "王五", Age = 16, Address = "四川" });

        // _list.ItemsSource = peopleList;
        //_comBox2.ItemsSource = peopleList;

        for (int i = 0; i < 5; i++)
        {
            MenuModel parent = new MenuModel();
            parent.Name = $"一級選單{i}";
            for (int j = 0; j < 5; j++)
            {
                MenuModel children = new MenuModel();
                children.Name = $"二級選單{j}";
                parent.Children.Add(children);
            }

            menuModels.Add(parent);
        }

        //_Menu2.ItemsSource = menuModels;
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        System.Windows.MessageBox.Show("點選了一個普通按鈕");
    }

    private void ToggleButton_Click(object sender, RoutedEventArgs e)
    {
        System.Windows.MessageBox.Show($"您選擇了{sender}");
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        string str = string.Empty;
        //if (ck1.IsChecked.Value) 
        //{
        //    str += ck1.Content + ",";
        //}
        //if (ck2.IsChecked.Value)
        //{
        //    str += ck2.Content + ",";
        //}
        //if (ck3.IsChecked.Value)
        //{
        //    str += ck3.Content + ",";
        //}
        //if (ck4.IsChecked.Value)
        //{
        //    str += ck4.Content + ",";
        //}

        System.Windows.Forms.MessageBox.Show(str);
    }

    int count = 0;

    private void RepeatButton_Click(object sender, RoutedEventArgs e)
    {
        System.Windows.Forms.MessageBox.Show($"重複時間:{DateTime.Now.ToLongDateString()}.{DateTime.Now.Millisecond},重複次數:{count++}");
        Console.WriteLine($"重複時間:{DateTime.Now.ToLongDateString()}.{DateTime.Now.Millisecond},重複次數:{count++}");
    }

    private void Button_Click_2(object sender, RoutedEventArgs e)
    {
        //TextRange textRange = new TextRange(_richTextBox.Document.ContentStart, _richTextBox.Document.ContentEnd);
        //MessageBox.Show(textRange.Text);

        //Paragraph paragraph = new Paragraph();
        //Run run = new Run($"當前時間是{DateTime.Now}");
        //run.Foreground = Brushes.Red;
        //paragraph.Inlines.Add(run);
        //_richTextBox.Document.Blocks.Add(paragraph);
    }

    private void Expander_Expanded(object sender, RoutedEventArgs e)
    {
        System.Windows.Forms.MessageBox.Show("展開事件");
    }

    private void Expander_Collapsed(object sender, RoutedEventArgs e)
    {
        System.Windows.Forms.MessageBox.Show("關閉事件");
    }

    private void Button_Click_Result(object sender, RoutedEventArgs e)
    {
        //_TextBlock.Text = $"Item ={(listBox.SelectedItem as Person).Name},Value={listBox.SelectedValue}";
    }

    private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //var selectDto = listBox.SelectedItem as Person;
        //_name.Text = selectDto.Name;
        //_age.Text = selectDto.Age+"";
        //_address.Text = selectDto.Address;
    }

    private void _list_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //var dataDto = _list.SelectedItem as Person;
        //if (dataDto == null) return;

        //_name.Text = dataDto.Name;
        //_age.Text = dataDto.Age + "";
        //_address.Text = dataDto.Address;
    }

    private void _comBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //var dataDto = _comBox2.SelectedItem as Person;
        //if (dataDto == null) return;

        //_name.Text = dataDto.Name;
        //_age.Text = dataDto.Age + "";
        //_address.Text = dataDto.Address;
    }

    private void _comBox1_TextChanged(object sender, TextChangedEventArgs e)
    {
        //_phone.Text = _comBox1.Text;
    }

    private void tabCon_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
       // var tab = tabCon.SelectedItem as TabItem;

        //showCon.Text = $"選中tab是{tab.Header},選中的內容是{tab.Content}";
    }

    private void Button_Click_3(object sender, RoutedEventArgs e)
    {

    }

    //private void OpenMeida(object sender, RoutedEventArgs e)
    //{
    //    var openFileDialog = new Microsoft.Win32.OpenFileDialog()
    //    {
    //        Multiselect = false,
    //        Filter = "影片檔案(.mp4)|*.mp4"
    //    };

    //    if (openFileDialog.ShowDialog() == true)
    //    {
    //        file = openFileDialog.FileName;
    //        _MdiuElement.MediaOpened -= _MdiuElement_MediaOpened;
    //        _MdiuElement.MediaOpened += _MdiuElement_MediaOpened;
    //        _MdiuElement.Source = new Uri(file);
    //        this.Title = file;
    //        this._TextBlock.Text = file;
    //    }
    //}

    //private void _MdiuElement_MediaOpened(object sender, RoutedEventArgs e)
    //{
    //    if (_MdiuElement.NaturalDuration.HasTimeSpan)
    //    {
    //        _ProgressBar.Value = _MdiuElement.NaturalDuration.TimeSpan.TotalMilliseconds;
    //    }
    //}

    //private void PlayMeida(object sender, RoutedEventArgs e)
    //{
    //    _MdiuElement.Play();
    //   // _TextBlock.Visibility = Visibility.Collapsed;
    //}
    //private void StopMeida(object sender, RoutedEventArgs e)
    //{
    //    _MdiuElement.Pause();
    //}
    //private void BackMeida(object sender, RoutedEventArgs e)
    //{
    //    _MdiuElement.Position = _MdiuElement.Position - TimeSpan.FromSeconds(10);
    //}
    //private void ForwardMeida(object sender, RoutedEventArgs e)
    //{
    //    _MdiuElement.Position = _MdiuElement.Position + TimeSpan.FromSeconds(10);
    //}
    //private void Slider_ValueChange(object sender, RoutedEventArgs e)
    //{
    //    _MdiuElement.Volume = _Slider.Value;
    //}

    //private void Button_Click_ItemControl(object sender, RoutedEventArgs e)
    //{
    //    var itemCollec = _ItemControl.Items;
    //}

    //private void Button_Click_3(object sender, RoutedEventArgs e)
    //{
    //    MessageBox.Show($"當前選中數量{calendar.SelectedDates.Count},當前選中日期{calendar.SelectedDate}");
    //}

    //private void Button_Click_4(object sender, RoutedEventArgs e)
    //{
    //    MessageBox.Show($"文字值:{datepickerstrat.SelectedDate}-{datepickerend.SelectedDate},\r\n{datepickerstrat.Text}-{datepickerend.Text}");
    //}

    //private void Button_Click_SelectRoot(object sender, RoutedEventArgs e)
    //{
    //    FolderBrowserDialog dialog = new FolderBrowserDialog();
    //    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    //    {
    //        _TetxBox.Text = "";
    //        _TetxBox.Text = dialog.SelectedPath;
    //        LoadTreeView(dialog.SelectedPath);
    //    }
    //}

    //private void LoadTreeView(string selectedPath)
    //{
    //    //設定根節點
    //    TreeViewItem treeViewItem = new TreeViewItem();
    //    treeViewItem.Header = "根目錄";

    //    //載入子檔案和資料夾
    //    LoadSubDiractory(treeViewItem, selectedPath);

    //    _TreeView.Items.Add(treeViewItem);
    //}

    //private void LoadSubDiractory(TreeViewItem treeViewItem, string selectedPath)
    //{
    //    DirectoryInfo directoryInfo = new DirectoryInfo(selectedPath);

    //    //載入資料夾
    //    foreach (var item in directoryInfo.GetDirectories())
    //    {
    //        TreeViewItem subTreeViewItem = new TreeViewItem();
    //        subTreeViewItem.Header = item.Name;

    //        LoadSubDiractory(subTreeViewItem, item.FullName);
    //        treeViewItem.Items.Add(subTreeViewItem);
    //    }

    //    //載入檔案
    //    foreach (var item in directoryInfo.GetFiles())
    //    {
    //        TreeViewItem subTreeViewItem = new TreeViewItem();

    //        subTreeViewItem.Header = item.Name;
    //        treeViewItem.Items.Add(subTreeViewItem);
    //    }
    //}

    //private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
    //{
    //    TreeViewItem treeNode = _TreeView.SelectedItem as TreeViewItem;
    //    if (treeNode != null)
    //    {
    //        System.Windows.MessageBox.Show(treeNode.Header.ToString());
    //    }
    //}

    private void MenuItem_Click(object sender, RoutedEventArgs e)
    {
        var menuItem = sender as System.Windows.Controls.MenuItem;
        System.Windows.Forms.MessageBox.Show(menuItem.Header.ToString());
    }

    private void Border_PreviewMouseUp(object sender, MouseButtonEventArgs e)
    {
        //_contentMenu.IsOpen = true;
    }
}

相關文章