私の目的は次のとおりです。 でTabItem
名前付きの「タブ」をダブルTabControl
クリックするTabControl
と、折りたたまれ、別のダブルクリックで展開されます。しかし、 を移動して「タブ」をダブルクリックして折りたたむと、列の高さが の高さと等しくない、つまり従わないことGridSplitter
が正しく機能しません。 「TabControl」。TabControl
TabControl
GridSplitter
.xaml
<Window x:Class="WpfApplication7.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" MinHeight="20"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid Grid.Column="1">
<Label>
Nothing
</Label>
</Grid>
</Grid>
<GridSplitter Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Height="6" />
<TabControl Grid.Row="2"
TabStripPlacement="Bottom"
VerticalAlignment="Stretch">
<TabItem Header="Tab"
MouseDoubleClick="TabItemDoubleCilck">
<!--ListView-->
<ListView Grid.Row="1"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<ListView.View>
<GridView>
<GridViewColumn Header="AA "
Width="100"
DisplayMemberBinding="{Binding [0]}" />
<GridViewColumn Header="BB"
Width="100"
DisplayMemberBinding="{Binding [1]}" />
<GridViewColumn Header="CC"
Width="100"
DisplayMemberBinding="{Binding [2]}" />
<GridViewColumn Header="DD"
Width="100"
DisplayMemberBinding="{Binding [3]}" />
</GridView>
</ListView.View>
<ListViewItem>
<x:Array Type="sys:String" >
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
</x:Array>
</ListViewItem>
<ListViewItem>
<x:Array Type="sys:String" >
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
<sys:String>2000/01/01</sys:String>
</x:Array>
</ListViewItem>
</ListView>
</TabItem>
</TabControl>
</Grid>
</Window>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication7
{
/// <summary>
/// MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
const double dBottomTabMinHeight = 20.0;
private bool isBottomTabUnfold;
public MainWindow()
{
InitializeComponent();
isBottomTabUnfold = true;
}
private void TabItemDoubleCilck(object sender, MouseButtonEventArgs e)
{
TabItem tabItm = sender as TabItem;
if (isBottomTabUnfold)
{
((FrameworkElement)tabItm.Parent).Height = dBottomTabMinHeight;
}
else
{
((FrameworkElement)tabItm.Parent).Height = Double.NaN;
}
isBottomTabUnfold = !isBottomTabUnfold;
}
}
}