Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It was not easy,but I realized what shall I do to fix this bug. My idea is to use custom Convertor, but I haven't any clever thoughts How to send ConverterParameter into convertor. But I've found solution. Here is my convertor:</p> <pre><code>public class SeparatorConverter : IValueConverter { private Visibility _visible; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var element = (TextBlock) value; element.Loaded += ElementLoaded; return _visible; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return null; //not needed } private static void ElementLoaded(object sender, RoutedEventArgs e) { var element = sender as TextBlock; var parentItemsControl = element.FindParent(x =&gt; x is ItemsControl) as ItemsControl; var parentPanel = element.FindParent(x =&gt; x is Panel) as Panel; if (parentItemsControl == null || element == null || parentPanel== null) return; var itemText = parentPanel.FindName("MyTextBlock") as TextBlock; var collection = parentItemsControl.ItemsSource as IEnumerable&lt;string&gt;; if (itemText == null || collection == null) return; var list = collection.ToList(); if (list.IndexOf(itemText.Text) == list.Count() - 1) // Can be incorrect because we can have two same items element.Visibility = Visibility.Collapsed; } } </code></pre> <p>Find parent function:</p> <pre><code>public static DependencyObject FindParent(this DependencyObject element, Func&lt;DependencyObject, bool&gt; filter) { DependencyObject parent = VisualTreeHelper.GetParent(element); if (parent != null) { if (filter(parent)) { return parent; } return FindParent(parent, filter); } return null; } </code></pre> <p>Here is my XAML code:</p> <pre><code> &lt;Coverters:SeparatorConverter x:Key="SeparatorVisibilityConverter"&gt; &lt;/Coverters:SeparatorConverter&gt; &lt;ItemsControl Grid.Row="1" ItemsSource="{Binding Value, IsAsync=False}"&gt; &lt;ItemsControl.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;WrapPanel&gt; &lt;/WrapPanel&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ItemsControl.ItemsPanel&gt; &lt;ItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;WrapPanel&gt; &lt;TextBlock x:Name="MyTextBlock" Text="{Binding}" Style="{StaticResource TextBlockInListViewItem}" TextWrapping="WrapWithOverflow"/&gt; &lt;TextBlock x:Name="commaTextBlock" Style="{StaticResource TextBlockInListViewItem}" Text=", " Visibility="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource SeparatorVisibilityConverter}}"/&gt; &lt;/WrapPanel&gt; &lt;/DataTemplate&gt; &lt;/ItemsControl.ItemTemplate&gt; &lt;/ItemsControl&gt; </code></pre> <p>Ok. Any way, If you have another idea how to fix this bug, you could post your answer here=)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload