Card doesn't display the header when in a ListBox

Fundamentals for Avalonia Forum

Posted 16 days ago by Michael R. Taylor
Avatar

I have a Card in the DataTemplate for a ListBox and for some reason, the header doesn't show. I even added the "IsHeaderVisible=True". This is on Linux, if that matters. Am I missing something? Here is the code and a screenshot of the output. {Binding Conversion} creates the "Fahrenheit -> Celsius" in the first Card and "Fahrenheit -> Kelvin" in the second Card.

        <ListBox ItemsSource="{Binding Conversions}" Focusable="False">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <actipro:Card IsHeaderVisible="True">
                        <actipro:Card.Header>
                            <TextBlock Text="{Binding Value}" FontWeight="Bold"/>
                        </actipro:Card.Header>
                        <actipro:Card.Content>
                            <TextBlock Text="{Binding Conversion}" HorizontalAlignment="Center"/>
                        </actipro:Card.Content>
                    </actipro:Card>
                    <!-- <DockPanel> -->
                    <!--     <Label DockPanel.Dock="Left" FontSize="12" VerticalAlignment="Center" Content="{Binding Index}" /> -->
                    <!--     <Label DockPanel.Dock="Top" FontSize="20" HorizontalAlignment="Center" Content="{Binding Value}" /> -->
                    <!--     <Label DockPanel.Dock="Bottom" FontSize="14" HorizontalAlignment="Center" Content="{Binding Conversion}" /> -->
                    <!-- </DockPanel> -->
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

Comments (2)

Posted 16 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Michael,

I tried creating something similar using Card as ListBoxItem and everything appeared as expected.  I tested on Windows, but would not expect Windows or Linux to have any impact here.  I notice from your screenshot that your Card entries don't look like the default theme for Card.  Do you have a custom theme or style being applied somewhere that might be overring or otherwise interfering with the Card header?

If you still think this is something specific to Card, could you please try to recreate it using a simple sample project and send to our support email address?  If so, please delete any bin/obj folders before zipping and then reference this forum post in the email.


Actipro Software Support

Answer - Posted 15 days ago by Michael R. Taylor
Avatar

Hello, thank you for your reply.

You mentioning "themes" made me double-check the documentation and look at my App.axaml, and I noticed that I forgot to add Includes="Pro" to my <actipro:ModernTheme /> line. Adding that fixes the problem.

Thank you for your help!

Add Comment

Please log in to a validated account to post comments.