zoukankan      html  css  js  c++  java
  • WPF的ChildWindow

    WPF不像Silverlight中有直接的ChildWindow,所以一般设置子窗口的时候,我们通常想到的是使用UserControl,今日看到别人早有贴出帖子,添加引用使用微软的子窗口:

          <extToolkit:ChildWindow x:Name="childWindow" Visibility="Visible" Height="800" Width="1100"  Background="Transparent"
                                   CloseButtonVisibility="Collapsed" WindowBackground="Black" WindowOpacity="0.92"  BorderThickness="0" BorderBrush="Black" Caption="" ClipToBounds="False" Focusable="False" IsHitTestVisible="False" IsManipulationEnabled="True" IsModal="True">
                <Grid Background="Black" Opacity="1" >
                    <Grid Margin="90" ClipToBounds="False">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="70"/>
                            <RowDefinition Height="100"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal" Grid.Row="0">
                            <Image  HorizontalAlignment="Left"  Height="64" Width="64" Name="image1" Stretch="Fill" VerticalAlignment="Bottom"
                                Source="/Yeylol.NetworkSettings;component/Styles/Images/btn_back.png" />
                            <Label Content="Password"  HorizontalAlignment="Left" Margin="20,0,0,0" Foreground="White" FontSize="42" Name="label1"
                               VerticalAlignment="Bottom" />
                        </StackPanel>
                        <Grid Grid.Row="1">
                            <Border CornerRadius="7" Width="765" Height="43" Margin="30,0,0,0" BorderThickness="1" BorderBrush="#FF737070" Background="Silver">
                                <StackPanel Orientation="Horizontal" Background="{x:Null}" >
                                    <PasswordBox  Height="35" HorizontalAlignment="Left" Name="txtPassword" Margin="4" VerticalAlignment="Center" Width="700"
                                     Background="White" Padding="5" FontSize="18"/>
                                    <Button Content="OK" Height="35" Name="btnOK" Width="50" Foreground="White">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Rectangle>
                                                    <Rectangle.Fill>
                                                        <VisualBrush>
                                                            <VisualBrush.Visual>
                                                                <StackPanel>
                                                                    <StackPanel.Background>
                                                                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1" >
                                                                            <GradientStop Color="#414457" Offset="0.5" />
                                                                            <GradientStop Color="#1D1E33" Offset="0.5" />
                                                                        </LinearGradientBrush>
                                                                    </StackPanel.Background>
                                                                    <TextBlock FontSize="20" Margin="15,10">OK</TextBlock>
                                                                </StackPanel>
                                                            </VisualBrush.Visual>
                                                        </VisualBrush>
                                                    </Rectangle.Fill>
                                                </Rectangle>
                                            </ControlTemplate>
                                        </Button.Template>

                                    </Button>
                                </StackPanel>
                            </Border>
                        </Grid>

                    
                        <Grid Grid.Row="2" Margin="0,100,0,0"  Opacity="1" >


                        </Grid>
                    </Grid>

                </Grid>
            </extToolkit:ChildWindow>

    不过此窗口不能像silverlight的子窗口那样可以设置窗口的样式:WindowStyle="none",此处只能隐藏掉关闭按钮,窗口的样式设置颜色后,跟存放控件的内容部分还有有一个白色的边,我设置了很久都没设置掉,不知道是不是本人技术不行,索性添加一个Window作为子窗口使用模态,样式也好设置,在mvvm中也不用那么麻烦的传值。

    经验在于积累,没解决一个问题都需要总结小小,这样才会进步,希望大家多多指教,有不足之处敬请赐教

  • 相关阅读:
    Java实现 LeetCode 474 一和零
    Java实现 LeetCode 474 一和零
    Java实现 LeetCode 473 火柴拼正方形
    Java实现 LeetCode 473 火柴拼正方形
    Java实现 LeetCode 473 火柴拼正方形
    Java实现 LeetCode 472 连接词
    Java实现 LeetCode 472 连接词
    df 和 du 命令详解
    如何使用UDP进行跨网段广播
    从linux启动到rootfs的挂载分析
  • 原文地址:https://www.cnblogs.com/Cindys/p/2377654.html
Copyright © 2011-2022 走看看