如何在WPF XAML中声明的C#中为矩形着色? [英] How do you color a rectangle in C# that has been declared in XAML in WPF?

查看:39
本文介绍了如何在WPF XAML中声明的C#中为矩形着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在WPF中XAML中声明的C#中为矩形着色?

How do you color a rectangle in C# that has been declared in XAML in WPF?

XAML中有一个矩形控件.在我的C#代码中,有时最好填充背景色.如何做到这一点?

There is a rectangle control in XAML. In my C# code there are times in which it would be nice to fill the background color. How does one do this?

推荐答案

对我有用的方法是拥有一个嵌入式文本块并将背景更改为该文本块.

The way that worked for me is to have an embedded textblock and change the background to the textblock.

这篇关于如何在WPF XAML中声明的C#中为矩形着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆