我有一个Grid
,它有多行。在我的网格的第一行中,我有DataGrid
来显示点击Tree
时的内容。
如果TreeView
中点击的值没有内容,则应在grid.row=0
而不是DataGrid
中显示NO-COntent。
我该怎么做?我已将Visibility
设置为collapsed
到TextBox
。当没有内容时,我已经在代码中Visible
了。
将TextBox放置在任何位置时,它可以正常工作,但不能放在Grid.Row=0.
XAML
<Grid>
<Grid.RowDefinitions>
<RowDefinition Name="grid" Height="*"/>
<RowDefinition Name="horzspliter" Height="5"/>
<RowDefinition Name="detailview" Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Height="23" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Name="textBlock1" Text="No-Content" Visibility="Collapsed" Width="500" />
// Text Block Is not displayed in the Grid.Row="0"
<my:DataGrid Grid.Row="0" />
</Grid>
Code behind
if (!File.Exists(path))
{
this.textBlock1.Visibility = Visibility.Visible;
}
else
{
this.textBlock1.Visibility = Visibility.Collapsed;
//Do Datagrid Operations
}
如何在DataGrid Hidden
本身中将其显示为Grid.Row=0
?
答案 0 :(得分:0)
网格与您的TextBox
重叠。您可以在显示Collapsed
时将网格可见性设置为TextBox
,或者在XAML中使用TextBox
更改DataGrid
的声明顺序,并且您的TextBox将呈现在DataGrid
的顶部。