2013-10-19 85 views
1

我有兩個堆疊面板在另一個,內部有一個可見性「摺疊」,它的名稱爲「verborgen」 當mouseOver內部堆疊面板需要更改爲可見性時 因此我使用TargetName =「verborgen」TargetName找不到

但是,它總是回到我verborgen‘「名稱’無法識別

<DataTemplate x:Key="WastebinTemplate"> 
      <ContentControl map:MapLayer.Position="{Binding GeoLocation}"> 
       <ContentControl.Content> 
        <StackPanel> 
          <TextBlock Background="{StaticResource Blue}" Text="{Binding Barcode}"/> 
         <StackPanel x:Name="verborgen" Visibility="Collapsed" 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.Resources> 
       <Style TargetType="StackPanel"> 
        <Style.Triggers> 
         <Trigger Property="IsMouseOver" Value="True"> 
          <Setter Property="Visibility" Value="Visible" TargetName="verborgen" /> 
          <Setter Property="Panel.ZIndex" Value="9999"/> 
         </Trigger> 
        </Style.Triggers> 
       </Style> 
      </DataTemplate.Resources> 
     </DataTemplate> 
+0

您在上一篇文章中有答案。刪除一個。 –

回答

0

找到了,問題是我只是使用了datatemplate.trigger一個DataTemplate的風格,而不是

<Window x:Class="Oefening2.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:map="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF" 
     xmlns:model="clr-namespace:Oefening2.model" 
     Title="Wastebins in Kortrijk" WindowState="Maximized"> 
    <Window.Resources>   
     <model:LocationType x:Key="LocationTypeInstance"/> 
     <DataTemplate x:Key="WastebinTemplate"> 
      <ContentControl map:MapLayer.Position="{Binding GeoLocation}"> 
       <ContentControl.Content> 
        <StackPanel> 
          <TextBlock Background="{StaticResource Blue}" Text="{Binding Barcode}"/> 
         <StackPanel x:Name="verborgen" Visibility="Collapsed" 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.Triggers> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter TargetName="verborgen" Property="Visibility" Value="Visible"/> 
        <Setter Property="Panel.ZIndex" Value="9999" /> 
       </Trigger> 
      </DataTemplate.Triggers> 
     </DataTemplate> 
    </Window.Resources> 
    <Grid x:Name="Root"> 
     <map:Map x:Name="myMap" CredentialsProvider="AnlnVG80DKkOfS5KLoUofPfy8t0a6AdtJvynRT_rxvV8MQ6cy6eEhQ6MHPBd5P3c" ZoomLevel="14" Center="50.8333,3.2667" MouseDoubleClick="MapWithPushpins_MouseDoubleClick"> 
      <map:MapItemsControl ItemsSource="{Binding Wastebins}" ItemTemplate="{StaticResource WastebinTemplate}" /> 
     </map:Map> 
    </Grid> 
</Window>