首页 > 其他分享 >WPF所有原生空间使用demo

WPF所有原生空间使用demo

时间:2024-04-27 16:44:58浏览次数:26  
标签:原生 sender -- demo void object private new WPF

//前台窗体
<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;
    }
}

 

标签:原生,sender,--,demo,void,object,private,new,WPF
From: https://www.cnblogs.com/SmallChen/p/18162217

相关文章

  • 芯科SiWx917学习笔记:1-测试Out of Box Demo
    实验目的:测试OutofBoxDemo实验环境:SimplicityStudioV5实验器材:WirelessStarterKitMainboard(BRD4002ARevA06)+ SiWG917SingleBandWi-FiandBLE8MBFlashRadioBoard(BRD4338ARevA01)实验开始:1.新建工程:在demos中找到OutofBoxDemo(SoC)应用演示工程......
  • SignalR服务端嵌入到WPF
    用的是.netframework4.7.2的WPF。<Windowx:Class="EBServerTry.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:......
  • h5使用原生麦克风
    conststartButton=document.getElementById('chart_button');    constinputText=document.getElementById('chatui_input');     //initrecognition    constrecognition=newwebkitSpeechRecognition();     functi......
  • .net开源智能家居之小米米家的c#原生sdk【MiHome.Net】1.0.0发布
    背景介绍hi大家好,我是三合,作为一个非著名懒人,智能家居简直刚需,在上一篇文章他来了他来了,.net开源智能家居之苹果HomeKit的c#原生sdk【Homekit.Net】1.0.0发布,快来打造你的私人智能家居吧中有靓仔提到,没有苹果设备,有一说一,苹果手机很贵,并且原生支持苹果HomeKit的智能家居设备......
  • dotnet 简单方法在一个进程内同时跑起 WPF 和 ASP.NET Core 框架
    从设计架构上,无论是WPF还是ASP.NETCore框架,都是在dotnet运行时上层的应用,两个框架处于平级的结构。理论上讲,两个平级的框架只要不存在特殊的情况,都是能够相容存在的。本文将和大家介绍一个非常简单的方法,在一个进程内同时跑起WPF和ASP.NETCore框架在一个进程内同时跑......
  • 他又来了,.net开源智能家居之小米米家的c#原生sdk【MiHome.Net】1.0.0发布,快来打造你的
    背景介绍hi大家好,我是三合,作为一个非著名懒人,智能家居简直刚需,在上一篇文章他来了他来了,.net开源智能家居之苹果HomeKit的c#原生sdk【Homekit.Net】1.0.0发布,快来打造你的私人智能家居吧中有靓仔提到,没有苹果设备,有一说一,苹果手机很贵,并且原生支持苹果HomeKit的智能家居设备也......
  • 记 Intel 的 31.0.101.5186 版本驱动带崩 WPF 程序
    本文记录一个Intel显卡驱动问题,暂时只在IntelUHDGraphics770显卡带31.0.101.5186版本的显卡驱动时,才概率复现问题显卡驱动31.0.101.5186版本是在2024.01.24之前发布的,在出现问题的设备上的表现是,运行任何的WPF应用程序,都会闪崩,最多窗口创建出来,但是没有任何窗口内......
  • WPF 基础绘图 创建和加工图片
    本文将从控制台开始,告诉大家一个非常简单的WPF基础绘图方法,通过本文的方法可以调用WPF上层人类友好的方法,充分利用GPU资源,创建或加工图片,最终结果可以输出到本地文件,可支持编码出多种不同的图片格式本文仅用到WPF的多媒体渲染层,在WPF的这一层上的API是人类友好的,直接......
  • wpf DataTemplate 动态模板内容
     <DataGridTemplateColumnWidth="50"Header="选择">              <DataGridTemplateColumn.CellTemplate>                <DataTemplate>                       ......
  • WPF RICHTEXTBOX 和数据库读写图文的方法。
    存入数据库。publicstringtoxaml(){//Streams=newMemoryStream();//其他的什么Stream类型都没问题XamlWriter.Save(MemoryStreams=newMemoryStream();TextRangedocumentTextRange=newTextRange(thi......