Announcement

Collapse
No announcement yet.

XamlListBox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XamlListBox

    Have you used XamlListBox plugin?
    it seems like a very useful wigdet but because Xaml tags are contained within double brackets, whatever is in there is read "as is" which leaves no room for variables. So everything is static text.
    At least the example provided by the developer of plugin uses Xaml in that way.

    Plugin can be found here:
    https://www.reteset.net/products/ams-plugins-bundle/

    Here is what Xaml tags look like:
    Code:
    strXamlSample1 = [[
    <Border BorderThickness="0">
    <Grid TextElement.FontSize="13" VerticalAlignment="Top" Margin="0">
    <Grid.ColumnDefinitions >
    <ColumnDefinition Width="3*"/>
    <ColumnDefinition Width="2*"/>
    <ColumnDefinition Width="150"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition/>
    </Grid.RowDefinitions>
    
    <StackPanel Margin="0, 0, 0, 0" Grid.Column="0">
    
    <TextBlock Background="#95BE00" Padding="2" FontSize="12" FontWeight="Bold">
    Item Details
    </TextBlock>
    <Grid Margin="2">
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="70"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    
    <StackPanel>
    <TextBlock Foreground="Black" FontWeight="Bold" Text="Item"/>
    <TextBlock Foreground="Black" FontWeight="Bold" Text="Notes"/>
    </StackPanel>
    <StackPanel Grid.Column = "1">
    <TextBlock Foreground="Black" TextAlignment="Left" Text="Holland Pavers"/>
    <TextBlock TextAlignment="Left" TextWrapping="Wrap" Text="This is a long description of this item. This is a long description of this item."/>
    
    </StackPanel>
    </Grid>
    </StackPanel>
    
    
    <StackPanel Margin="0, 0, 0, 0" Grid.Column="1">
    <TextBlock Background="#95BE00" Padding="2" FontSize="12" FontWeight="Bold">Unit \ Quantity</TextBlock>
    <StackPanel Margin="2">
    <Grid >
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="80"/>
    <ColumnDefinition Width="2*"/>
    </Grid.ColumnDefinitions>
    
    <StackPanel>
    <TextBlock>Unit</TextBlock>
    <TextBlock>Quantity</TextBlock>
    <TextBlock>Supplier</TextBlock>
    </StackPanel>
    <StackPanel Grid.Column = "1">
    <TextBlock TextAlignment="Left" Text="Square Feet"/>
    <TextBlock TextAlignment="Left" Text="2,500"/>
    <TextBlock TextAlignment="Left" TextWrapping="Wrap">ABC Landscape Supplies</TextBlock>
    
    </StackPanel>
    
    </Grid>
    
    </StackPanel>
    </StackPanel>
    
    <StackPanel Margin="0, 0, 0, 0" Grid.Column="2">
    <TextBlock Background="#95BE00" Padding="2" FontSize="12" FontWeight="Bold">Cost \ Price</TextBlock>
    <StackPanel Margin="2">
    <Grid >
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    
    <StackPanel>
    <TextBlock>Unit Cost</TextBlock>
    <TextBlock>Total Cost</TextBlock>
    <TextBlock>Unit Price</TextBlock>
    <TextBlock>Total Price</TextBlock>
    </StackPanel>
    <StackPanel Grid.Column = "1">
    <TextBlock TextAlignment="Right" Text="24.75"/>
    <TextBlock TextAlignment="Right" Text="2,559.57"/>
    <TextBlock TextAlignment="Right" Text="35.50"/>
    <TextBlock TextAlignment="Right" Text="3,201.97"/>
    </StackPanel>
    </Grid>
    
    </StackPanel>
    </StackPanel>
    
    </Grid>
    </Border>
    
    ]]

    I attach screencapture of how it looks when a loop is applied.

    Code:
    min = 1;
    max = 50;
    for count = min, max do
    XamlListBox.AddItem("SampleLB", strXamlSample1, "", "");
    end
    Obviously text is just repeated. But what about variable text?

    I tried appending variable string but it does not work.

    Thanks for any help.

    David R.
    Attached Files

  • #2
    pm me with a direct link to those pluginsClick image for larger version

Name:	error.JPG
Views:	183
Size:	13.6 KB
ID:	307059
    i cant use the web installer

    Comment


    • #3
      Long strings can also be concatenated, just terminate it:

      Code:
      local myVar = 10;
      local myString = [[
        hello world ]] .. tostring(myVar) .. [[
        good day world]];
      Bas Groothedde
      Imagine Programming :: Blog

      AMS8 Plugins
      IMXLH Compiler

      Comment


      • #4
        Originally posted by startup View Post
        pm me with a direct link to those pluginsClick image for larger version

Name:	error.JPG
Views:	183
Size:	13.6 KB
ID:	307059
        i cant use the web installer
        That's how reteset does it now you have to use the installer, downloading 3rd party versions is risky and not recommended.
        Plugins or Sources MokoX
        BunnyHop 2021 Here

        Comment


        • #5
          Originally posted by Imagine Programming View Post
          Long strings can also be concatenated, just terminate it:

          Code:
          local myVar = 10;
          local myString = [[
          hello world ]] .. tostring(myVar) .. [[
          good day world]];
          Hi Bas
          in the context of Xaml tags, concatenate by terminating does not work. I just tried it.
          Thanks

          David R.

          Comment


          • #6
            Try this example I found in my archives
            XamlListBox - Example 2.apz

            Comment


            • #7
              Originally posted by daviz View Post

              Hi Bas
              in the context of Xaml tags, concatenate by terminating does not work. I just tried it.
              Thanks

              David R.
              Can you show me how you attempted it? Long strings can always be concatenated, however syntax matters.
              Bas Groothedde
              Imagine Programming :: Blog

              AMS8 Plugins
              IMXLH Compiler

              Comment


              • #8
                Originally posted by Imagine Programming View Post

                Can you show me how you attempted it? Long strings can always be concatenated, however syntax matters.
                I forgot to include my attempt, sorry.
                Concatenate is almost at the end


                Code:
                amountPackages = 50
                
                strXamlSample1 = [[
                <Border BorderThickness="0">
                <Grid TextElement.FontSize="15" VerticalAlignment="Top" Margin="0">
                <Grid.ColumnDefinitions >
                <ColumnDefinition Width="44"/>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                </Grid.RowDefinitions>
                
                <StackPanel Margin="0, 0, 0, 0" Grid.Column="0">
                <Grid Margin="2">
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="22"/>
                </Grid.ColumnDefinitions>
                
                <StackPanel Grid.Column = "0">
                <TextBlock Background="#426f9e" Foreground="#ffffff" TextAlignment="Center" Text='%s'/>
                </StackPanel>
                
                </Grid>
                </StackPanel>
                
                
                
                <StackPanel Margin="0, 0, 0, 0" Grid.Column="1">
                <Grid Margin="2">
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                
                <StackPanel Grid.Column = "0">
                <TextBlock Foreground="Black" TextAlignment="Left" Text='012798'/>
                </StackPanel>
                
                </Grid>
                </StackPanel>
                
                
                <StackPanel Margin="0, 0, 0, 0" Grid.Column="2">
                <Grid Margin="2">
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                
                <StackPanel Grid.Column = "0">
                <TextBlock Foreground="Black" TextAlignment="Left" Text=]]..tostring('%s')..[[/>
                </StackPanel>
                
                </Grid>
                </StackPanel>
                
                
                
                <StackPanel Margin="0, 0, 0, 0" Grid.Column="3">
                <Grid Margin="2">
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                
                <StackPanel Grid.Column = "0">
                <TextBlock Foreground="Black" TextAlignment="Left" Text='20/05/2021'/>
                </StackPanel>
                
                </Grid>
                </StackPanel>
                
                
                </Grid>
                </Border>
                
                ]]
                and here is applied:

                Code:
                XamlListBox.SetUpdate("SampleLB", false);
                XamlListBox.DeleteAllItems("SampleLB");
                
                min = 1;
                max = 3;
                for count = min, max do
                local s = string.format(strXamlSample1,count,amountPackages)
                XamlListBox.AddItem("SampleLB", s, "", "");
                
                end
                XamlListBox.SetUpdate("SampleLB", true);
                it does not show error message, just Xaml list appears blank.

                David R.

                Comment


                • #9
                  Originally posted by colc View Post
                  Try this example I found in my archives
                  [ATTACH]n307069[/ATTACH]
                  Colc, thanks for the example, works great!
                  I need to delve deeper into pure LUA to get the hang of it (string.format).

                  David R.

                  Comment


                  • #10
                    Your second format parameter (]]..tostring('%s')..[[) has no quotes around it, that might make a difference. You stated that the concatenation didn't work, however it did or you would've got a syntax error. The quotes for a Text= attribute might be required, however I can't tell as I don't know the Xaml implementation used in the listbox.
                    Bas Groothedde
                    Imagine Programming :: Blog

                    AMS8 Plugins
                    IMXLH Compiler

                    Comment


                    • #11
                      Originally posted by Imagine Programming View Post
                      Your second format parameter (]]..tostring('%s')..[[) has no quotes around it, that might make a difference. You stated that the concatenation didn't work, however it did or you would've got a syntax error. The quotes for a Text= attribute might be required, however I can't tell as I don't know the Xaml implementation used in the listbox.
                      Hi Bas you are right, if it was wrong, an error message would pop up.
                      I will try again with quotes.
                      Thanks a lot.

                      David

                      Comment

                      Working...
                      X