我想将一个渲染的“ImageSource”(从UserControl)绑定到“Image”(在Window中),但它不起作用。
如果我在“UserControl”之前放置“Image”,它将呈现一次,但是当我更改数据时,“Image”仍然相同。
ImageView(UserControl):
public ImageSource RenderedImageSource
{
get
{
ImageCanvas.Measure(new Size(ImageCanvas.Width, ImageCanvas.Height));
ImageCanvas.Arrange(new Rect(new Size(ImageCanvas.Width, ImageCanvas.Height)));
ImageCanvas.UpdateLayout();
//Others code to render this UserControl
}
}
}
在XAML(窗口)中:
<Window>
<Canvas>
<local:ImageView x:Name="RenderView" Canvas.Left="15" Canvas.Top="44" ></local:ImageView >
<Image Source="{Binding RenderedImageSource, ElementName=RenderView}" Width="421" Height="614"></Image>
</Canvas>
</Window>
感谢您的帮助