Home > Net >  WPF listview control in ItemTemplate template Item hidden failure
WPF listview control in ItemTemplate template Item hidden failure

Time:09-21

In the software I use template custom the listviewitem style, which according to the context of a hidden, but still in the interface can be selected to hide in the


The code below
 & lt; Style TargetType="ListView" & gt; 


BorderThickness="1" CornerRadius="5"
The Visibility="{Binding the Converter={StaticResource DeviceVisibilityConverter}}"
HorizontalAlignment="Center" VerticalAlignment="Center"
Background="{Binding Path=Background, RelativeSource={RelativeSource FindAncestor=Mode, AncestorType={x: Type ListBoxItem}}}" & gt;
HorizontalAlignment="Center" VerticalAlignment="Center"
Text="{Binding the Converter={StaticResource DeviceIdConverter}, StringFormat=Id: {0}}"/& gt;





<style TargetType="ListViewItem" & gt;
<style. Triggers>


</style>


</style>

CodePudding user response:

And this should be hidden items can be selected to
I use the Visibility in the border="{Binding the Converter={StaticResource DeviceVisibilityConverter}}" the hidden, but it feels like just the template for the hidden ListviewItem not be hidden

CodePudding user response:

Converter code look to send back to attribute is set to try Collapsed

CodePudding user response:

refer to the second floor groveer response:
look converter code to send return property is set to try Collapsed

Return to attribute is Collapsed
CommunicationModel internally, I define a class, breakpoint tried, I did return the Collapsed, it feels like it's border is hidden, but listviewItem has
 public object Convert (object value, Type targetType, object parameter, CultureInfo culture) 
{
If (the value is CommunicationModel)
Return the Visibility. Visible;
The else
{
Return the Visibility. Collapsed;
}
}

CodePudding user response:

reference zaaserz reply: 3/f
Quote: refer to the second floor groveer response:

Converter code look hair return property is set to try Collapsed

Return to attribute is Collapsed
CommunicationModel internally, I define a class, breakpoint tried, I did return the Collapsed, it feels like it's border is hidden, but listviewItem has
 public object Convert (object value, Type targetType, object parameter, CultureInfo culture) 
{
If (the value is CommunicationModel)
Return the Visibility. Visible;
The else
{
Return the Visibility. Collapsed;
}
}

Breakpoint debugging value value to see whether the value value

CodePudding user response:

reference 4 floor groveer response:
breakpoint debugging value value to see whether the incoming value value reason


Value value is correct, no, this, according to the desired flow is Visible from previous return last returned to the Collapsed, it should not be this problem, because I have to set the visibility to force the border Collapsed then all items are the situation, so I doubt that is the question of style
 & lt; The Border Width="80" Margin="3" BorderBrush="SteelBlue" 
BorderThickness="1" CornerRadius="5"
The Visibility="Collapsed"
HorizontalAlignment="Center" VerticalAlignment="Center"
Background="{Binding Path=Background, RelativeSource={RelativeSource FindAncestor=Mode, AncestorType={x: Type ListBoxItem}}}" & gt;
HorizontalAlignment="Center" VerticalAlignment="Center"
Text="{Binding the Converter={StaticResource DeviceIdConverter}, StringFormat=Id: {0}}"/& gt;

  •  Tags:  
  • C#
  • Related