File path to file name String converter not working

后端 未结 1 1365
鱼传尺愫
鱼传尺愫 2021-01-27 06:07

Using a wpf ListBox I\'m trying to display a list of filename without displaying the full path (more convenient for user).

Data comes from an Observa

相关标签:
1条回答
  • 2021-01-27 06:26

    In ItemsSource binding converter applies to the whole list and not to each item in the collection. If you want to apply your converter per item you need to do it ItemTemplate

    <ListBox x:Name="VideoFileList" ItemsSource="{Binding Path=DataContext.VidFileDisplay, ElementName=Ch_Parameters}" ...>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Path=., Converter={StaticResource PathToFileName}}"/>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    
    0 讨论(0)
提交回复
热议问题