2013-10-19 54 views
0

其他堆栈面板上有两个堆栈面板。 因此,第一个堆叠面板始终可见并且具有条形码。 我想要第二个stackpanel x:Name =“Verborgen”Visiblity“Collapsed”在mouseOver时具有可见性“可见”,现在可见的堆叠面板需要有z-Index 9999.StackPanel visiblity在mouseOver上“可见”

这是Dropbox链接项目: https://www.dropbox.com/s/8w8horclhfwy4ub/Oefening2.zip

当我将此代码添加到Window.Resources但这是有点儿什么我想它不工作:

 <ControlTemplate x:Key="panelControl" TargetType="StackPanel"> 
      <ControlTemplate.Triggers> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter TargetName="Verborgen" Property="Visibility" Value="Visible"/> 
       </Trigger> 
      </ControlTemplate.Triggers> 
     </ControlTemplate> 

This is the xaml 
<Window.Resources>  
     <model:LocationType x:Key="LocationTypeInstance"/> 
     <DataTemplate x:Key="WastebinTemplate"> 
      <ContentControl map:MapLayer.Position="{Binding GeoLocation}"> 
       <ContentControl.Content> 
        <StackPanel Name="form"> 
          <TextBlock Background="{StaticResource Blue}" Text="{Binding Barcode}"/> 
         <StackPanel Visibility="Collapsed" x:Name="Verborgen" Background="{StaticResource Orange}">        
          <Button Name="btnRemove" Content="Remove wastebin" Click="btnRemove_Click"> 
          </Button> 
          <Label>Adres</Label> 
          <TextBox Name="txbAdres" Text="{Binding Address}"/> 
          <Label>Location type</Label> 
          <ComboBox ItemsSource="{Binding Source={StaticResource LocationTypeInstance}, Path=LocationTypes}" 
             DisplayMemberPath="Description" SelectedItem="{Binding LocationType}" SelectedValuePath="ID" SelectedValue="{Binding LocationType.ID}" /> 
          <Label>Capaciteit</Label> 
          <Slider Minimum="0" Maximum="100" TickFrequency="10" Value="{Binding Capacity}"></Slider> 
         </StackPanel> 
        </StackPanel> 
       </ContentControl.Content> 
      </ContentControl> 
     </DataTemplate> 
    </Window.Resources> 
+1

如何将鼠标悬停在已折叠的东西上? –

+0

另外,选中的项目(mouseOver)需要有z-index 9999,所以选中的项目总是可见的 – user2827958

+0

What ??????????? –

回答

0

试试这个:

<Window.Resources> 
    <Style x:Key="Expandable" TargetType="StackPanel"> 
     <Setter Property="Visibility" Value="Collapsed" /> 
     <Style.Triggers> 
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=StackPanel}, Path=IsMouseOver}" Value="True" > 
       <Setter Property="Visibility" Value="Visible" /> 
      </DataTrigger> 
     </Style.Triggers> 
    </Style> 

    <model:LocationType x:Key="LocationTypeInstance"/> 
    <DataTemplate x:Key="WastebinTemplate"> 
     <ContentControl> 
      <ContentControl.Content> 
       <StackPanel Name="form"> 
         <TextBlock Background="{StaticResource Blue}" Text="{Binding Barcode}"/> 
        <StackPanel x:Name="Verborgen" Background="{StaticResource Orange}" Style="{StaticResource Expandable}"> 
         <Button Name="btnRemove" Content="Remove wastebin" Click="btnRemove_Click"> 
         </Button> 
         <Label>Adres</Label> 
         <TextBox Name="txbAdres" Text="{Binding Address}"/> 
         <Label>Location type</Label> 
         <ComboBox ItemsSource="{Binding Source={StaticResource LocationTypeInstance}, Path=LocationTypes}" 
            DisplayMemberPath="Description" SelectedItem="{Binding LocationType}" SelectedValuePath="ID" SelectedValue="{Binding LocationType.ID}" /> 
         <Label>Capaciteit</Label> 
         <Slider Minimum="0" Maximum="100" TickFrequency="10" Value="{Binding Capacity}"></Slider> 
        </StackPanel> 
       </StackPanel> 
      </ContentControl.Content> 
     </ContentControl> 
    </DataTemplate> 

</Window.Resources> 
+0

谢谢你的回应,这个作品。 – user2827958