Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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# 在System.Controls.Image中渲染画布_C#_Wpf_Xaml - Fatal编程技术网

C# 在System.Controls.Image中渲染画布

C# 在System.Controls.Image中渲染画布,c#,wpf,xaml,C#,Wpf,Xaml,我有一个画布,我用路径填充可观察集合。我还使用它在我的列表视图中绘制缩略图,这会降低我在较低硬件上的性能 我知道我的observateCollection何时发生变化,所以我只想将其渲染为System.Controls.Image。(欢迎提出其他想法) 但是我什么也没找到——有很多表单的东西或者保存为文件。但我只想在运行时使用它 如何将我的画布渲染为系统控件.图像? 根据Ashs的建议,我尝试在视觉画笔中呈现它-什么都不呈现-即使我尝试从父级绑定datacontext

我有一个
画布
,我用路径填充
可观察集合
。我还使用它在我的
列表视图中绘制缩略图,这会降低我在较低硬件上的性能

我知道我的
observateCollection
何时发生变化,所以我只想将其渲染为
System.Controls.Image
。(欢迎提出其他想法)

但是我什么也没找到——有很多表单的东西或者保存为文件。但我只想在运行时使用它

如何将我的
画布
渲染为
系统控件.图像

根据Ashs的建议,我尝试在视觉画笔中呈现它-什么都不呈现-即使我尝试从父级绑定datacontext

                            <Rectangle Width="100"
                                       Height="100">
                                <Rectangle.OpacityMask>

                                    <VisualBrush>
                                        <VisualBrush.Visual>
                                            <custom:CustomPreviewSvgControl PreviewViewModel="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Rectangle}}}"
                                                                            Width="100"
                                                                            Height="100"
                                            />
                                        </VisualBrush.Visual>
                                    </VisualBrush>
                                </Rectangle.OpacityMask>
                            </Rectangle>


也许可以使用VisualBrush?我该怎么做?UIElements的ObservableCollection是错误的方法。改为使用ItemsControl,并将其绑定到数据项集合。然后使用DataTemplate可视化项目。从这里开始阅读:。你的意思是把
Canvas
当作
ItemsPanel
?因为我需要一个画布来将svg路径放在正确的位置?