如何在wpf中控制WebBrowser的层

时间:2017-01-24 04:24:08

标签: c# wpf webbrowser-control

我想让隐藏在ContentBorder下面的WebBorder。但它不会起作用。在这方面有谁能帮助我?

以下代码是我写的。

 <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="30" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition Width="300" />
    </Grid.ColumnDefinitions>
    <CheckBox Content="Option" Name="OptionCheck" IsChecked="True" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0, 0, 10, 0" Grid.Column="1" />
    <Border x:Name="WebBorder" Grid.Row="1" Margin="5, 30, 5, 5" Grid.ColumnSpan="2" BorderBrush="Black" BorderThickness="1">
        <WebBrowser Grid.Row="1" Margin="5" Source="http://www.msn.com/en-us" Grid.ColumnSpan="2" />
    </Border>
    <DockPanel LastChildFill="True" Grid.Column="1" Grid.Row="1">
        <Grid DockPanel.Dock="Right">
            <Expander Name="OptionExpander" IsExpanded="{Binding ElementName=OptionCheck, Path=IsChecked}">
                <Expander.Template>
                    <ControlTemplate  TargetType="{x:Type Expander}">
                        <Border Name="ContentBorder" Width="0">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="ContentBorder" Property="Width" Value="Auto" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Expander.Template>
                <Grid Background="#FF373837" Width="300">
                    <StackPanel Orientation="Vertical" Margin="10">
                        <TextBlock Text="Option" Foreground="White" FontWeight="Black" FontSize="25" />
                        <TextBlock Margin="10,10,0,0" Text="Change Color" Foreground="White" FontSize="15" />
                        <StackPanel Margin="10,10,0,0" Orientation="Horizontal">
                            <Border Width="40" Height="40" Background="Blue" />
                            <Border Width="40" Height="40" Background="Red" />
                            <Border Width="40" Height="40" Background="Yellow" />
                        </StackPanel>
                        <TextBlock Margin="10,10,0,0" Text="Change FontSize" Foreground="White" FontSize="15" />
                    </StackPanel>
                </Grid>
            </Expander>
        </Grid>
    </DockPanel>
</Grid>

选中复选框时,内容边框应显示在顶部。 但它隐藏在webbrowser的下方。

提前致谢。

0 个答案:

没有答案