2014-10-18 26 views
0

我有一個應用程序,有一些文本塊和按鈕,我正在嘗試加載TextBlock,隱藏整個網格後面,並根據我的可見性綁定再次顯示它。問題是,加載文本desapears但主柵格掩蓋了所有按鈕和東西的位置後面的網格。有沒有辦法很好地做到這一點?帶有文本框的遮掩網格WPF XAML

注意:沒有加載TextBlock,它通常只用矩形隱藏/顯示我的應用程序。

我的代碼如下所示:

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

回答

0

目前GridTextBlock一部分。由於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> 
+0

非常感謝的澄清。 – Dracke 2014-10-18 09:23:48