Dracke
Dracke

Reputation: 651

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. 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.

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>

Upvotes: 0

Views: 93

Answers (1)

dkozl
dkozl

Reputation: 33384

At the moment Grid is part of TextBlock. 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>
        <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>

Upvotes: 0

Related Questions