WPF中在同一个界面内有按钮和显示表格的区域,如何一按按钮就能在指定的区域显示一个表格?
展开全部
xaml代码:
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="97,254,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<Grid Height="184" HorizontalAlignment="Left" Margin="36,28,0,0" Name="grid1" Visibility="Collapsed" VerticalAlignment="Top" Width="396" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="93*" />
<ColumnDefinition Width="85*" />
<ColumnDefinition Width="87*" />
<ColumnDefinition Width="131*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="48*" />
<RowDefinition Height="58*" />
<RowDefinition Height="78*" />
</Grid.RowDefinitions>
</Grid>
</Grid>
code代码:
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
grid1.Visibility = Visibility.Visible;
}
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="97,254,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<Grid Height="184" HorizontalAlignment="Left" Margin="36,28,0,0" Name="grid1" Visibility="Collapsed" VerticalAlignment="Top" Width="396" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="93*" />
<ColumnDefinition Width="85*" />
<ColumnDefinition Width="87*" />
<ColumnDefinition Width="131*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="48*" />
<RowDefinition Height="58*" />
<RowDefinition Height="78*" />
</Grid.RowDefinitions>
</Grid>
</Grid>
code代码:
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
grid1.Visibility = Visibility.Visible;
}
更多追问追答
追问
我问的问题是:在这个界面内,有多个按钮,按下不同的按钮实现不同表格的切换,表格显示在按钮的下方
追答
事还挺多,还是你自己弄吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个很简单。举个最简单的例子,有个两行的Grid,第一行你放表格,第二行你放按钮。默认情况下表格的可见性为collapesd。然后在按钮的click事件里将表格的可见性设为visible就行了。
追问
具体怎样写代码呢?举个简单的例子好么?WPF菜鸟求指教
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询