Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I make a Xaml one liner?
    text
    copied!<p>lamp xamlI'm using the structure below a lot of times in DataTemplates to make little 'lamps' light up.</p> <p>Could I put it in a ContentPresenter or DataTemplate or anything like it to reduce the code to one line? </p> <p>The 'test' value is hardcoded in xaml for every lamp. I get a binding value with a Dictionary'&lt;'string, Signal> called Signals. </p> <p>I can't use a MultiBinding with a Converter since it uses just as many lines. Any ideas to make this a one liner in xaml?</p> <pre><code>&lt;StackPanel ToolTip="{Binding Signals[test].tooltip}"&gt; &lt;ContentPresenter Content="{Binding Signals[test].lampvalue}" ContentTemplate="{StaticResource GreenLampPresenter}" /&gt; &lt;TextBlock Text="test"/&gt; &lt;/StackPanel&gt; </code></pre> <p>It would be perfect if the example below was in fact a legal statement in xaml. I still want both the signal from my dictionary and the hardcoded value:</p> <pre><code>Content="{Binding Path=Signals[test], StringFormat='{0} test'}". </code></pre> <p>The case is that I have more than 100 of lamps like in the little image. And the state of the lamp is saved in the dictionary. If the lamp is not found in the dictionary it means that it is not wired up in the configuration (or in the physical controller). It still needs the little text I0 to identify it. <img src="https://i.stack.imgur.com/3JMMQ.png" alt="Green Lamp"> If I dont have the harcdcoded 'IO' value to name the lamp only a green will show. And in the physical controller the 'IO' value is always present.</p> <p>So please do suggest a valid solution containing both the values: Signal[test] and 'test' in one line :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload