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中也不用那么麻烦的传值。

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

 

 

转载于:https://www.cnblogs.com/Cindys/archive/2012/03/02/2377654.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值