Using XAML code in a 'foreach' formatting function

Started by PandDLong, May 19, 2025, 08:48:48 AM

Previous topic - Next topic

PandDLong


I am trying to insert a line break into a Text Overlay in the Batch Processor while using the 'foreach' formatting function. It is inserting the XAML code for a line break but it isn't interpreting the code.

This expression:  {File.MD.city|foreach:{value} {remaining|is:0,,+;pereplace:+==<LineBreak/>}}

gives:   City 1 <LineBreak/>City 2

I have tried various other ways to insert the <LineBreak/> but always get the same result.

Am I doing this wrong?  
Or am I expecting too much  (IMatch variables already do a lot) and XAML markup can't be used inside a 'foreach' loop?    

Thanks for the help

Michael


Mario

Where you use the variable, wrap it into

<TextBlock>Your variable here</TextBlock>


PandDLong


I still couldn't get it to work within a 'foreach' loop.

But, that is okay, there is another way.  My text overlay only has room for 4 entries (and it should never be more) so I will just use the 'index' function and manually enter the variables 4 times using index numbers 0,1,2 and 3 with a <LineBreak/> after each.



Michael

Mario

Very well. There is a complexity limit for IMatch and mixing XAML with foreach loops is maybe too much.

sinus

Quote from: PandDLong on May 20, 2025, 07:14:55 AMI still couldn't get it to work within a 'foreach' loop.

But, that is okay, there is another way.  My text overlay only has room for 4 entries (and it should never be more) so I will just use the 'index' function and manually enter the variables 4 times using index numbers 0,1,2 and 3 with a <LineBreak/> after each.



Michael

I am not sure, if I understand this correctly.
But, Michael, I tried this with Design&Print, and it works not, like you wrote.

Perhaps you could try some "tricks", I tried the following code

<TextBlock Width="700" TextWrapping="Wrap" FontFamily="Adobe Garamond Pro" FontSize="42pt" xml:space="preserve">{File.MD.city|foreach:{value}{remaining|is:0,,aaa;pereplace:aaa==                                    }}</TextBlock>
where the Width at the beginning and the spaces at the end (for replace) are important values to "play".

I get with these city-names:

Lana; New York; Bern; Paris; London; Marseille; Oberentfelden AG; Ruukki

the output in the attachement. But I do not often use the Batch processor, hence I do not know, if this could help.
Best wishes from Switzerland! :-)
Markus