gpt4 book ai didi

c# - 图像控件绑定(bind)生成的Imageurl

转载 作者:行者123 更新时间:2023-11-30 18:35:49 25 4
gpt4 key购买 nike

嘿,这是我在这里的第一个问题,因为我真的找不到我的问题的答案。通常我会检查论坛、谷歌和所有这些东西 5 次,但在这种情况下我没有找到任何解决方案,因为我没有得到我猜的关键字....

问题:我在我的 WP7 应用程序中有一个图像控件,并试图放入一个如下所示的 Uri:

http://veranstaltungen.meinestadt.de/images/image.php?origin=events&mode=G&id=71080093

问题是这个图像不是由控件加载的。像这样的图片,

http://www.design-center.de/wp-content/uploads/2012/09/IMG_1113.jpg-mini.jpg

加载没有任何问题。

有任何解决方法或其他控件的想法吗?

提前致谢

<DataTemplate>
<controls:PivotItem Margin="0,0,0,0">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<StackPanel Name="contentPanel" Margin="12,0,12,0">
<TextBlock x:Name="PartyTitle" Text="{Binding title}" Margin="10,0,0,10" Style="{StaticResource PhoneTextTitle2Style}" TextWrapping="Wrap"/>
<Image x:Name="PartyImage" Source="{Binding imgUrl}" Margin="10,0,0,10" ></Image>
<TextBlock x:Name="PartyDescription" Margin="10,0,0,10" Text="{Binding text}" TextWrapping="Wrap" />
<Button x:Name="PartyLink" DataContext="{Binding urls[0]}" Content="Link" Click="PartyLink_Click"></Button>
</StackPanel>
</ScrollViewer>
</controls:PivotItem>
</DataTemplate>

绑定(bind)和其他东西适用于所有控件。

最佳答案

您可以在代码后面下载图像并将其设置为源。我将发布一个示例。

这应该可以工作,但我的网络适配器无法在模拟器上工作。它总是一些东西。

  WebRequest req = WebRequest.Create("http://www.leenwallpapers.com/images/gallery/funny0152.jpg");
req.BeginGetRequestStream(new AsyncCallback(test), null);

HttpWebRequest 请求 = (HttpWebRequest)ar.AsyncState;

        // End the operation
Stream postStream = request.EndGetRequestStream(ar);
BitmapImage img = new BitmapImage();
img.SetSource(postStream);
imgtest.Source = img;

在本例中,imgtest 是我的 xaml 中图像控件的 x:name。您当然可以在 View 模型中执行此操作,并且 imgtest 可以是您设置的位图图像属性并引发更改的属性。

关于c# - 图像控件绑定(bind)生成的Imageurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14529855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com