Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带Base64String的ListView项目模板_C#_Wpf_.net 4.0 - Fatal编程技术网

C# 带Base64String的ListView项目模板

C# 带Base64String的ListView项目模板,c#,wpf,.net-4.0,C#,Wpf,.net 4.0,我正在处理一个C#图像,在这里我收到一条XML消息,其中一个元素是一个Base64编码的图像 我正在WPF元素中使用动态数据绑定,我想向列表项添加一个图像 下面是我目前使用的WPF <ListView Height="397" HorizontalAlignment="Left" Margin="491,29,0,0" Name="lstCallLogInformation" VerticalAlignment="Top" Width="320">

我正在处理一个C#图像,在这里我收到一条XML消息,其中一个元素是一个Base64编码的图像

我正在WPF元素中使用动态数据绑定,我想向列表项添加一个图像

下面是我目前使用的WPF

<ListView Height="397" HorizontalAlignment="Left" Margin="491,29,0,0" Name="lstCallLogInformation" 
                 VerticalAlignment="Top" Width="320">
            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Expander IsExpanded="True">
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" VerticalAlignment="Bottom" />
                                                </StackPanel>
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListView.GroupStyle>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <DockPanel>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding contactNameOrPhoneNumber}" FontWeight="Bold" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding dateString}" HorizontalAlignment="Left" />
                                <TextBlock Text="{Binding callDuration}" HorizontalAlignment="Right" />
                            </StackPanel>
                        </StackPanel>
                    </DockPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

因此,基本上在StackPanel中,我希望有如下内容:

<Image Source="{Binding myBase64EncodedProperty}" />


我找不到任何关于这是怎么可能的

您需要做的是将Base64字符串转换为
位图图像
。我不打算复制/粘贴或重复答案,但看看这个答案,你正试图解决的问题:

你可能需要先将它转换成C#中的图像。(这取决于编码图像的格式。)哪个版本的.NET?这确实会有所不同。