从C#隐藏SVG元素 [英] Hide SVG element from C#
本文介绍了从C#隐藏SVG元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个svg
,其中包含两个组.
I have a svg
which contains two groups.
<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg">
<g id="gr1" fill="white" stroke="green" stroke-width="5">
<circle cx="40" cy="40" r="25" />
<circle cx="60" cy="60" r="25" />
</g>
<g id="gr2" fill="white" stroke="green" stroke-width="5">
<circle cx="90" cy="60" r="25" />
<circle cx="96" cy="40" r="25" />
</g>
</svg>
有没有一种方法可以使用C#或javascript(最好是C#)在某个事件(按钮单击,x值> y值等)下隐藏组gr2?我知道visibility="hidden"
可以满足我的要求,但是我不知道如何为一组SVG调用它.
Is there a way, using C# or javascript (preferably C#), to hide the group gr2 at some event (button click, x value>y value, etc)? I know that visibility="hidden"
does what I want, but I don't know how to call it for a group of my SVG.
推荐答案
尝试一下:
<svg viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg">
<g id="gr1" fill="white" stroke="green" stroke-width="5">
<circle cx="40" cy="40" r="25" />
<circle cx="60" cy="60" r="25" />
</g>
<g runat="server" id="gr2" fill="white" stroke="green" stroke-width="5">
<circle cx="90" cy="60" r="25" />
<circle cx="96" cy="40" r="25" />
</g>
</svg>
和在C#
{
gr2.Visible = false;
}
这篇关于从C#隐藏SVG元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文