【问题标题】:change the image inside listview DataTemplate In WINRT在 WINRT 中更改 listview DataTemplate 中的图像
【发布时间】:2023-03-30 01:24:01
【问题描述】:

在 windows 应用程序 (WINRT) 中,我想在列表视图中动态更改图像,其中列表视图项由数据模板绑定

【问题讨论】:

    标签: winrt-xaml winrt-async


    【解决方案1】:

    图片是您的 listviewitem 模板的一部分吗?您可以添加列表项的图像源路径文本属性吗?如果您要动态更新值,您的列表项将需要实现 INotifyPropertyChanged 并在值更改时引发 PropertyChanged 事件。

    <DataTemplate>
        <Image Source="{Binding imageSourcePath}" />
    </DataTemplate>
    

    【讨论】:

    • 我想在不重新加载列表的情况下更改图像。例如在 asp.net 中使用 findcontrol
    • 在这个数据模板中我想根据下载状态改变图像
    • 您可以查看列表中的ContainerContentChanging 事件。当您的数据以这种方式加载时,您可以在 DataTemplate 中逐步填充您的 UI。
    • 例如,如果我在一个列表中有 20 张图片,我只想更改一张图片而不加载整个列表视图。
    猜你喜欢
    • 2017-02-07
    • 2019-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多