2015-03-30 100 views
0

我试图隐藏wp8.it的做工精细下拉列表中,但是显示space.How我可以删除这个空间,使向上和downwords基于显示/隐藏列表隐藏下拉在WP8

按钮组enter image description here

是否有其他方法来隐藏textblock.because System.Windows.Visibility.Collapsed不工作文本块。

<Grid HorizontalAlignment="Left" Height="661" Margin="0,130,0,0" VerticalAlignment="Top" Width="440"> 
          <Grid> 
           <TextBox HorizontalAlignment="Left" Height="65" Margin="-3,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="433" GotFocus="WatermarkTB_GotFocus" Foreground="Gray" 
      LostFocus="WatermarkTB_LostFocus" x:Name="txtsearch" Text="Search" BorderBrush="LightGray"/> 

           <toolkit:ListPicker x:Name="lstLocations" Foreground="Black" 
         BorderThickness="0.2" SelectionMode="Single" SelectionChanged="Locations_SelectionChanged" 
         VerticalAlignment="Bottom" Margin="10,0,23,500" BorderBrush="Black" Height="88" > 
            <toolkit:ListPicker.ItemTemplate> 
             <DataTemplate> 
              <StackPanel > 
               <TextBlock Text="{Binding name}" Foreground="Black" FontSize="18"/> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.ItemTemplate> 
            <toolkit:ListPicker.FullModeItemTemplate> 
             <DataTemplate> 
              <StackPanel> 
               <TextBlock Text="{Binding name}"         
             FontSize="28" 
                 Foreground="White" 
                           /> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.FullModeItemTemplate> 
           </toolkit:ListPicker> 

           <toolkit:ListPicker x:Name="lstSubLocations" Foreground="Black" 
         BorderThickness="0.2" SelectionMode="Single" SelectionChanged="lstSubLocations2_SelectionChanged" 
         VerticalAlignment="Bottom" Margin="10,0,23,460" ExpansionMode="FullScreenOnly" Visibility="Collapsed" BorderBrush="Black" Height="64" > 
            <toolkit:ListPicker.ItemTemplate> 
             <DataTemplate> 
              <StackPanel > 
               <TextBlock Text="{Binding name}" Foreground="Black" FontSize="18"/> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.ItemTemplate> 
            <toolkit:ListPicker.FullModeItemTemplate> 
             <DataTemplate> 
              <StackPanel> 
               <TextBlock Text="{Binding name}"         
             FontSize="28" 
                 Foreground="White" 
                           /> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.FullModeItemTemplate> 
           </toolkit:ListPicker> 

           <toolkit:ListPicker x:Name="lstSubLocations2" Foreground="Black" 
         BorderThickness="0.2" SelectionMode="Single" 
         VerticalAlignment="Bottom" Margin="10,0,23,390" ExpansionMode="FullScreenOnly" BorderBrush="Black" Height="64" Visibility="Collapsed" > 
            <toolkit:ListPicker.ItemTemplate> 
             <DataTemplate> 
              <StackPanel > 
               <TextBlock Text="{Binding name}" Foreground="Black" FontSize="18" /> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.ItemTemplate> 
            <toolkit:ListPicker.FullModeItemTemplate> 
             <DataTemplate> 
              <StackPanel> 
               <TextBlock Text="{Binding name}"         
             FontSize="28" 
                 Foreground="White" 
                           /> 
              </StackPanel> 
             </DataTemplate> 
            </toolkit:ListPicker.FullModeItemTemplate> 
           </toolkit:ListPicker> 
          </Grid> 
          <Grid Margin="0 170 0 0"> 
           <Button Content="Search Jobs" x:Name="Serachjob" FontSize="20" Foreground="White" HorizontalAlignment="Left" Margin="0,172,0,0" VerticalAlignment="Top" Width="204" Grid.ColumnSpan="2" BorderThickness="0" Click="Serachjob_Click"> 
            <Button.Background> 
             <ImageBrush Stretch="Fill" ImageSource="/Image/jobseeker.png"/> 
            </Button.Background> 

           </Button> 
           <Button Content="Advanced Search" x:Name="Advanced_Search" Foreground="White" FontSize="20" HorizontalAlignment="Left" Margin="202,172,0,0" VerticalAlignment="Top" Width="215" BorderThickness="0" Click="Advanced_Search_Click"> 
            <Button.Background> 
             <ImageBrush Stretch="Fill" ImageSource="/Image/loginEmp.png"/> 
            </Button.Background> 
           </Button> 
           <Button Content="Post Resumes" x:Name="Post_Resume" FontSize="20" Foreground="White" HorizontalAlignment="Left" Margin="0,222,0,0" VerticalAlignment="Top" Width="204" Grid.ColumnSpan="2" BorderThickness="0" Click="Post_Resume_Click"> 
            <Button.Background> 
             <ImageBrush Stretch="Fill" ImageSource="/Image/jobseeker.png"/> 
            </Button.Background> 

           </Button> 
           <Button Content="Browse Jobs" x:Name="Browse_Jobs" Foreground="White" FontSize="20" HorizontalAlignment="Left" Margin="202,222,0,0" VerticalAlignment="Top" Width="215" BorderThickness="0" Click="Browse_Jobs_Click"> 
            <Button.Background> 
             <ImageBrush Stretch="Fill" ImageSource="/Image/loginEmp.png"/> 
            </Button.Background> 
           </Button> 

          </Grid> 


         </Grid> 
+0

发布您的XAML代码或更加描述您的问题。如果你在'StackPanel'中有你的控件,那么使用Collapsed会导致所有东西都被推上去。基本上,如果控制不存在于Visual Tree中。 – 2015-03-31 00:05:10

+0

@ChubosaurusSoftware thnks for reply.I已更新问题与我的XAML文件 – hii 2015-03-31 06:54:18

回答

1

问题是,您在该网格上使用的是Margin。具体来说这一个,

<Grid Margin="0 170 0 0"> 

如果要根据内容自动调整大小尝试使用网格RowDefinition设置为Auto并把你的控件在各个行。

或者您可以使用StackPanel来放置您的控件。您也可以在Grid内使用StackPanel

事情是这样的:

<Grid x:Name="LayoutRoot" Background="#FFAAAAAA"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 

    <Grid Grid.Row="0" Background="#FFD8CCFF"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition/> 
     </Grid.ColumnDefinitions> 
     <TextBlock Text="Dogecoin WP8" Foreground="Black" Margin="12,0"/> 
     <TextBlock x:Name="StatusLabel" Grid.Column="1" Text="" HorizontalAlignment="Right" Padding="0,0,12,0" Foreground="Black"/> 
    </Grid> 

    <StackPanel Grid.Row="1" Margin="0,5,0,0"> 
    <!-- TODO: your controls here --> 
    </StackPanel> 
</Grid> 

然后展开或隐藏ListPicker是内部可折叠StackPanel/Grid应该导致这种

enter image description here

看看它是如何一切下推时ListPicker已扩展?

作为一个方面说明,当你想要反应的东西时要小心使用Margins

+0

我真的很感激你的回应,并教我如何使用margin.But我的主要问题是。我使用级联下拉式。如果我选​​择像印度的国家,然后自动城市下拉菜单出现.on c#编码我只是隐藏城市下拉,当我隐藏它也获得空间。这就是为什么这个按钮显示belolw.how我可以处理这.. ..? – hii 2015-03-31 19:11:53

+0

@hii是的,我知道你在说什么hii。你使用两个'ListPicker's。你想要做的是摆脱那个边距,然后使用'StackPanel'。在'StackPanel'里面包含你的两个'ListPicker's然后你的一组按钮。然后隐藏任何ListPicker将导致项目被推高(无空格)。 – 2015-03-31 19:28:35