数据网格可见性 [英] Datagrid Visibility
问题描述
你好
我目前正在攻读基础学位,这是我完成第一次作业的一部分,我们必须使用datagrid来输入数据.
I am currently undergoing a foundation degree in which I am part of the way through our first assignment which we have to use a datagrid to input data.
我需要的是不"访问的数据网格.在输入数据时可见,然后单击完成时,我需要显示数据网格.在Google上进行多次搜索后,我只能看到如何隐藏没有用的列,而且我似乎找不到 正确的答案.
What I need is the datagrid to "not" be visible when inputting data and then when I click finish I need the datagrid to appear. After many searches on google I can only see how to hide columns which is not useful and I cant seem to find the right answer.
这只是我可以在Datagrid属性中执行的操作,然后将其编码为一个按钮以重新出现,还是需要全部代码
Is this just something I can do in Datagrid properties and then code it to a button to re-appear or would it need to be all code
非常感谢
Gareth
Gareth
推荐答案
您可以通过将XGrid中的Visbility属性设置为Hidden或Collapsed来隐藏DataGrid.标记:
You can hide a DataGrid by setting its Visbility property to either Hidden or Collapsed, either in the XAML markup:
<DataGrid x:Name="dg1" Visibility="Collapsed" />
...或以编程方式:
...or programmatically:
dg1.Visibility = Visibility.Collapsed;
Visibility.Collaps和Visibility.Hidden之间的区别: http://stackoverflow.com/questions/886742/difference-between-visibility-隐藏和隐藏
然后您可以通过将Visiblity属性设置回其默认值Visible来显示它:
You can then display it by setting the Visiblity property back to its default value of Visible:
private void OnClick(object sender, RoutedEventArgs e)
{
dg1.Visibility = Visibility.Visible;
}
<Button Content="Display" Click="OnClick" />
希望有帮助.
Hope that helps.
请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.
这篇关于数据网格可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!