# Set Compound widget visibilty from within itself

**URL:** <https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165>\
**Category:** HMI & Visualization\
**Tags:** mapp-view\
**Created:** [May 14, 2024, 8:44am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165 "2024-05-14T08:44:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 14, 2024, 8:44am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/1 "2024-05-14T08:44:06Z")

</div>

Hey,  
I am trying to hide and show a compound widget from within itself, triggered by the change of a bound variable.  
This is some example code of what I would like to achieve, but it doesn’t work in the current form:

```auto
<EventBinding id="VarChange">
	<Source xsi:type="this.Event" event="SelectedBlockChanged" />
	<EventHandler condition="value &lt;&gt; 0">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="false" />
			</Target>
		</Action>
	</EventHandler>
	<EventHandler condition="value = 0">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="true" />
			</Target>
		</Action>
	</EventHandler>
</EventBinding>

```

I know it would be possible to publish the event and react to it outside the compound widget but I’d prefer an encapsulated solution.

Thanks  
Tim

---

<div class="post-metadata">

**Author:** ![wenbo.ruan](https://avatars.discourse-cdn.com/v4/letter/w/FF8800/32.png) [@wenbo.ruan](https://community.br-automation.com/u/wenbo.ruan)\
**Post date:** [May 14, 2024, 8:53am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/2 "2024-05-14T08:53:16Z")

</div>

Hello Tim Göhringer,

When using an event binding, no opcUa, session and clients system events are permitted, only events that comes with the widgets, so directly it wouldn’t be possible.

One workaround I did in the past, was to use and invisible widget (one that can bond with an numeric value), and detect when value changes and then set the overall visiblity based on the output of the said invisible widget.

Regards

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 14, 2024, 9:03am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/3 "2024-05-14T09:03:11Z")

</div>

Sorry, I forgot to mention. I am binding one local Property to an OPC UA Variable and react to the change of the local property.

One more thing, would it alternatively be possible to bind the Compound widget visibility to a local property/hidden Input?

---

<div class="post-metadata">

**Author:** ![wenbo.ruan](https://avatars.discourse-cdn.com/v4/letter/w/FF8800/32.png) [@wenbo.ruan](https://community.br-automation.com/u/wenbo.ruan)\
**Post date:** [May 14, 2024, 9:22am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/4 "2024-05-14T09:22:44Z")

</div>

Hello,

I took a look at help regarding the [local properties](https://help.br-automation.com/#/en/4/visualization%2Fmappview%2Fengineering%2Flv_customwidgets%2Flv_customwidgets_compound%2Flv_customwidgets_compound_edit%2Fv_customwidgets_compound_localproperty.html) , and it seems that the event ValueChanged of local properties can be responded in the event binding of the compound widget. For more information, the link above is set the help page regarding that,

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 14, 2024, 9:34am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/5 "2024-05-14T09:34:38Z")

</div>

Yes, that’s what I am doing currently. The Event is not the problem, setting the Compound widget visibility in that event is.

---

<div class="post-metadata">

**Author:** ![Simon\_Stoll](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/simon_stoll/32/445_2.png) [@Simon\_Stoll](https://community.br-automation.com/u/Simon_Stoll)\
**Post date:** [May 16, 2024, 9:13am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/6 "2024-05-16T09:13:28Z")

</div>

Hi Tim,

I don’t know whether it is possible to set the entire CompoundWidget invisible inside itself.

You could put all widgets of CompoundWidget in a GroupBox and set it invisible or change style of Widgets.  
But place in content will be always be reserved for pseudo invisble CompoundWidget. 😕

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 16, 2024, 9:27am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/7 "2024-05-16T09:27:34Z")

</div>

Thanks for your answer. Sadly I have to control the visibility of all Compound widgets indivually, so I cant group them.  
But one thing I found, if you put the compound widgets inside of a FlexLayoutPanel no gaps are existant when making Widgets invisible.

---

<div class="post-metadata">

**Author:** ![Simon\_Stoll](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/simon_stoll/32/445_2.png) [@Simon\_Stoll](https://community.br-automation.com/u/Simon_Stoll)\
**Post date:** [May 16, 2024, 9:41am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/8 "2024-05-16T09:41:59Z")

</div>

What I meant, was to put all widgets **inside** the CompoundWidget in a GroupBox.

Really interesting thing about the FlexLayoutPanel…

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 16, 2024, 9:53am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/9 "2024-05-16T09:53:56Z")

</div>

Ah ok, now I understood. In this case your point with the reserved space stands, because the widget didnt really changed for the overlying MappView Content.

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 17, 2024, 8:25am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/10 "2024-05-17T08:25:06Z")

</div>

After a bit of further experimenting and talks with B&R Support I managend to find what I was looking for.  
Although (I think) not documented anywhere, it is possible to access the local property `visible` and probably others the same way you can access self created local properties.

This means you can hide the entire compound widget from within itself, just like from outside, with this action:

```auto
<EventBinding id="HideWidget">
	<Source xsi:type="widget.Event" widgetRefId="Btn_HideWidget" event="Click" />
	<EventHandler condition="">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="false" />
			</Target>
		</Action>
	</EventHandler>
</EventBinding>

```

---

<div class="post-metadata">

**Author:** ![florent.boissadier](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@florent.boissadier](https://community.br-automation.com/u/florent.boissadier)\
**Post date:** [May 24, 2024, 1:04pm UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/11 "2024-05-24T13:04:08Z")

</div>

Hi Tim,

I already had the discussion with B&R Support in France about this, you have the possibility to use this to set invisible the compound widget but you cannot set him visible afterward.  
As Support say me, this feature should be available in AS6.

---

<div class="post-metadata">

**Author:** ![tim.oc](https://avatars.discourse-cdn.com/v4/letter/t/FF8800/32.png) [@tim.oc](https://community.br-automation.com/u/tim.oc)\
**Post date:** [May 27, 2024, 7:37am UTC](https://community.br-automation.com/t/set-compound-widget-visibilty-from-within-itself/3165/12 "2024-05-27T07:37:49Z")

</div>

I cannot confirm this. Of course you cannot react to button clicks when the compound widget is invisible. But you can still react to value changes of e.g. DropDowns and change the visibility that way.

The change you are talking about is probably this:

> [@B&R Automation Studio 6 Features](https://community.br-automation.com/t/b-r-automation-studio-6-features/2979/3):
>
> Compound Widget Enhancements:
> 
> - Within a compound widget, it’s now possible to bind structure elements to local properties, such as the enable, visible, or a specific local property within the compound widget.
