Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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

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# WPF-如何更改按钮';以编程方式创建图像_C#_Wpf_Aforge - Fatal编程技术网

C# WPF-如何更改按钮';以编程方式创建图像

C# WPF-如何更改按钮';以编程方式创建图像,c#,wpf,aforge,C#,Wpf,Aforge,我正在创建一个wpf应用程序,并使用Forge在我的项目中实现usb网络摄像头。在我的CameraWindow中,我有一个Image控件,用于显示从usb网络摄像头拍摄的最新图像 在我的第三个窗口(AllCapturedImages)中,我有一个图像控件 我正在显示usb网络摄像头拍摄的最新图像。这是使用myCameraWindow中的Action()实现的 <Image x:Name="newlyAddedImage" Margin="10,10,230,10"/> public

我正在创建一个wpf应用程序,并使用Forge在我的项目中实现usb网络摄像头。在我的
CameraWindow
中,我有一个
Image
控件,用于显示从usb网络摄像头拍摄的最新图像

在我的第三个窗口(
AllCapturedImages
)中,我有一个
图像
控件 我正在显示usb网络摄像头拍摄的最新图像。这是使用my
CameraWindow
中的
Action()
实现的

<Image x:Name="newlyAddedImage" Margin="10,10,230,10"/>

public Action<BitmapImage> newlyCapturedImage;
if (newlyCapturedImage != null)
{
    newlyCapturedImage(CapturedImages.Last());
}

我想要的是每次我拍摄图像时更改/更新这些
图像
源代码

如果您像这样定义
按钮
控制模板

<Button x:Name="PreviewButton1" Margin="577,10,25,404">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <ContentPresenter />
        </ControlTemplate>
    </Button.Template>
</Button>

谢谢你的回答<代码>
这是我的
图像
控件,我现在可以在其中显示最新捕获的图像。我已经测试了您对我的第二个
图像
控件的回答,但它没有显示任何内容:/n如果您暂时尝试将按钮的内容设置为文本块会怎么样?:PreviewButton1.Content=new TextBlock(){Text=“TEST”};你看到课文了吗?什么也没发生。我的意思是,我看不到文本。如果你把零件全部拆了怎么办。你看到按钮了吗?是的,当我移除
并开始工作时,我看到了按钮我的意思是
PreviewButton1.Content=newImage(){Source=newImage}我可以在第二张
图像中看到最新捕获的图像
控制wtf。。。
<Button x:Name="PreviewButton1" Margin="577,10,25,404">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <ContentPresenter />
        </ControlTemplate>
    </Button.Template>
</Button>
var bitmapImage = CapturedImages.Last();
PreviewButton1.Content = new Image() { Source = bitmapImage };