简体   繁体   English

使用文本框WPF XAML遮盖网格

[英]Overshadow Grid with textbox WPF XAML

I have an application with some text blocks and buttons and I am trying to do Loading TextBlock, that hides whole grid behind it and than shows it again, based on my visibility binding. 我有一个带有一些文本块和按钮的应用程序,我正在尝试执行“加载TextBlock”,该操作将整个网格隐藏在其后,然后根据可见性绑定再次显示该网格。 The problem is, that the Loading text desapears but the Main grid overshadows the grid behind where are all the buttons and stuff. 问题是,“加载”文本消失了,但是“主”网格使所有按钮和填充物后面的网格都变得模糊了。 Is there a way hot to do it properly? 有没有办法正确地做到这一点?

Note: without the Loading TextBlock it works normally with just a rectangle hiding/showing my application. 注意:没有Loading TextBlock,它只能在隐藏/显示我的应用程序的矩形下正常工作。

My code looks like this: 我的代码如下所示:

<Grid Margin="2" Background="Black">

<Border BorderThickness="2" BorderBrush="Black">
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="LOADING..." Visibility="{Binding DownloadingWeather, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=False}" FontSize="20" Foreground="White">

    <Grid Visibility="{Binding DownloadingWeather, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=True}">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Color="Gray" Offset="0.0" />
                <GradientStop Color="Black" Offset="0.5" />
                <GradientStop Color="Black" Offset="0.7" />
                <GradientStop Color="Gray" Offset="1.0" />
            </LinearGradientBrush>
        </Grid.Background>

        <Grid Grid.Row="4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <!-- Some Stuff like buttons and textblocks here-->

        </Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="3*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Some Stuff like buttons and textblocks here-->

    </Grid>
    </TextBlock>
</Border>
</Grid>

At the moment Grid is part of TextBlock . 目前, GridTextBlock一部分。 Because Border can take only one child you need to create a Grid that holds both Text and Grid that you want show exclusively 由于Border可以采取只生一个孩子,你需要创建一个Grid是同时拥有TextGrid要完全展示

<Border>
    <Grid>
        <TextBlock ... Text="LOADING..." Visibility="{Binding DownloadingWeather, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=False}"/>
        <Grid Visibility="{Binding DownloadingWeather, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=True}">
            <!-- Grid content -->
        </Grid>
    </Grid>
</Border>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM