Can you put expressions in attribute tags? attr="{2*pi}"

Example: I’m trying to programmatically output a phrase and show the red word in red. Notice the bang (!) in the second Visibility=“{!red}”. Is this legal?


partList = [
 	{part: 'This word is ', 	red: 0},
 	{part: 'red', 	red: 1},
 	{part: '!' ,	red: 0} ] 


<Each Items=“{partList}">
	<Text Value=“{part}” Visibility=“{red}” TextColor=“#f00" />
	<Text Value=“{part}” Visibility=“{!red}” TextColor=“#000" />

A lot of things are legal in UX expressions, but your question isn’t actually about them. You seem to have assumed that the best solution to achieve what you needed was to render two text elements on top of each other, hiding one that doesn’t match a particular criteria.

Well, that is definitely not the way to do it, and Fuse offers a far better alternative. I present you, MatchKey (see the second example there)!

Here’s a working complete, minimal example:

    var list = [
        {part: "one", style: "notRed"},
        {part: "two", style: "red"},
        {part: "three", style: "notRed"}
    module.exports = {
        list: list
    <WrapPanel Alignment="VerticalCenter">
        <Each Items="{list}" MatchKey="style">
            <Text ux:Template="red" Value="{part}" TextColor="#f00" />
            <Text ux:Template="notRed" Value="{part}" TextColor="#000" />

Thank you!!!