Ignoring unsupported property 'Visibility'
Inside a DataTemplate of a ListBoxItem I am trying to set DataTrigger but I am getting the warning " Ignoring unsupported property 'Visibility' ". It also happens whit the Text property of a TextBlock.
Here is part of the code
Am I doing something wrong or this behaviour is not allowed?
Thank you
Here is part of the code
Code: Select all
<ListBox.ItemTemplate>
<DataTemplate>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
Thank you
-
-
sfernandez
Site Admin
- Posts: 2537
- Joined:
Re: Ignoring unsupported property 'Visibility'
I need a bit more of information.
Could you please post also the VisualTree of the DataTemplate?
I guess it contains an element named RevisionsList, right?
Could you please post also the VisualTree of the DataTemplate?
I guess it contains an element named RevisionsList, right?
Re: Ignoring unsupported property 'Visibility'
Of course. Yes, it contains an element with that name.
Code: Select all
<ListBox.ItemTemplate>
<DataTemplate>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
<StackPanel>
<Grid Height="30" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" x:Name="NameCell"/>
<ColumnDefinition Width="1*" x:Name="PlayersCell"/>
<ColumnDefinition Width="1*" x:Name="FitnessCell"/>
<ColumnDefinition Width="1*" x:Name="TechnicsCell"/>
<ColumnDefinition Width="1*" x:Name="TacticsCell"/>
<ColumnDefinition Width="1*" x:Name="FunCell"/>
<ColumnDefinition Width="1*" x:Name="TypeCell"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" x:Name="Test" Content="{Binding Scene.Name}" VerticalAlignment="Center" Width="{Binding ActualWidth, ElementName=NameColumn}" HorizontalAlignment="Center" />
<Label Grid.Column="1" Content="{Binding Path=Scene.Players, Converter={StaticResource PlayersToTextConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="2" Content="{Binding Path=Scene.Fitness, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="3" Content="{Binding Path=Scene.Technics, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Grid.Column="4" Content="{Binding Path=Scene.Tactics, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="5" Content="{Binding Path=Scene.Fun, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Viewbox Grid.Column="6" Width="24" Height="24" >
<Path x:Name="Icon" Fill="Black" Data="{StaticResource Animations}" />
</Viewbox>
</Grid>
<ListBox x:Name="RevisionsList" Visibility="Visible" ItemsSource="{Binding Revisions}" SelectedItem="{Binding SelectedRevision}" >
<ListBox.ItemTemplate>
<DataTEmplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTEmplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
-
-
sfernandez
Site Admin
- Posts: 2537
- Joined:
Re: Ignoring unsupported property 'Visibility'
As I imagined, you are specifying the VisualTree of the template after the Triggers, so elements are not registered yet. If you try your xaml in a WPF editor (like Kaxaml) it will complain about a missing reference to an object too.
Just declare first the VisualTree and later the Triggers:
Just declare first the VisualTree and later the Triggers:
Code: Select all
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid Height="30" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" x:Name="NameCell"/>
<ColumnDefinition Width="1*" x:Name="PlayersCell"/>
<ColumnDefinition Width="1*" x:Name="FitnessCell"/>
<ColumnDefinition Width="1*" x:Name="TechnicsCell"/>
<ColumnDefinition Width="1*" x:Name="TacticsCell"/>
<ColumnDefinition Width="1*" x:Name="FunCell"/>
<ColumnDefinition Width="1*" x:Name="TypeCell"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" x:Name="Test" Content="{Binding Scene.Name}" VerticalAlignment="Center" Width="{Binding ActualWidth, ElementName=NameColumn}" HorizontalAlignment="Center" />
<Label Grid.Column="1" Content="{Binding Path=Scene.Players, Converter={StaticResource PlayersToTextConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="2" Content="{Binding Path=Scene.Fitness, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="3" Content="{Binding Path=Scene.Technics, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Grid.Column="4" Content="{Binding Path=Scene.Tactics, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Label Grid.Column="5" Content="{Binding Path=Scene.Fun, Converter={StaticResource IntegerToStarSxmbolConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Viewbox Grid.Column="6" Width="24" Height="24" >
<Path x:Name="Icon" Fill="Black" Data="{StaticResource Animations}" />
</Viewbox>
</Grid>
<ListBox x:Name="RevisionsList" Visibility="Visible" ItemsSource="{Binding Revisions}" SelectedItem="{Binding SelectedRevision}" >
<ListBox.ItemTemplate>
<DataTEmplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTEmplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
<Setter TargetName="RevisionsList" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
Re: Ignoring unsupported property 'Visibility'
Thank you
. I didn't know that.

Who is online
Users browsing this forum: No registered users and 2 guests