【发布时间】:2013-05-17 05:52:34
【问题描述】:
我有一个Grid,它有多行。在我的网格的第一行中,我有一个DataGrid,当我的Tree 被点击时显示一些内容。
如果TreeView 中单击的值没有内容,则应在grid.row=0 中显示NO-CONntent,而不是DataGrid。
我该怎么做。我已将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
}
我怎样才能让它在Grid.Row=0 本身中可见并且我的DataGrid Hidden?
【问题讨论】:
标签: wpf datagrid grid visibility