Giter VIP home page Giter VIP logo

Comments (5)

timunie avatar timunie commented on May 29, 2024

As a workaround: would a Converter help you instead of two DataTemplates?

from avalonia.controls.itemsrepeater.

YoshihiroIto avatar YoshihiroIto commented on May 29, 2024

@timuenie
Thank you for your reply.

The sample I presented is a minimally reproducible code.
In production, the two DataTemplates are different in structure form each other.

For example. Here's another one I made up artificially

        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
            <ItemsRepeater Items="{Binding Items}">
                <ItemsRepeater.Layout>
                    <UniformGridLayout MinItemWidth="60" MinItemHeight="30" Orientation="Vertical" />
                </ItemsRepeater.Layout>

                <ItemsRepeater.ItemTemplate>
                    <views:DataTemplateSelector>
                        <views:DataTemplateSelector.Under100DataTemplate>
                            <DataTemplate DataType="viewModels:DataViewModel">
                                <StackPanel Width="60" Orientation="Horizontal">
                                    <Rectangle
                                        Width="16"
                                        Height="16"
                                        Fill="Red" />
                                    <TextBlock Foreground="Red" Text="{Binding Index}" />
                                </StackPanel>
                            </DataTemplate>
                        </views:DataTemplateSelector.Under100DataTemplate>

                        <views:DataTemplateSelector.Over100DataTemplate>
                            <DataTemplate DataType="viewModels:DataViewModel">
                                <Button
                                    Content="{Binding Index}"
                                    Foreground="Green" />
                            </DataTemplate>
                        </views:DataTemplateSelector.Over100DataTemplate>
                    </views:DataTemplateSelector>
                </ItemsRepeater.ItemTemplate>
            </ItemsRepeater>
        </ScrollViewer>
2022-09-17-08-44-20.mp4

Does your workaround still work in this situation?

from avalonia.controls.itemsrepeater.

timunie avatar timunie commented on May 29, 2024

I also have a workaround for this situation.

Just to be clear: I didn't say here you have a workaround, so this issue doesn't need to be fixed. But at the moment there are lots of efforts going on to prepare 11.0, so I don't know when this issue gets addressed. If you know a solution, PRs are welcome 🤗


My other workaround only works if you have two different DataTemplates: place both different controls into one DataTemplate and bind their IsVisible to the bool property you have.

And I have a third option: Use Avalonia.Behaviors

Happy coding

from avalonia.controls.itemsrepeater.

timunie avatar timunie commented on May 29, 2024

Related? #6

from avalonia.controls.itemsrepeater.

YoshihiroIto avatar YoshihiroIto commented on May 29, 2024

@timuenie
Thank you for your reply.

I was able to isolate whether this problem was on the Avalonia side or my implementation.

Thanks for the workaround suggestion.
I have confirmed that the problem is only reproduced with ItemsRepeater. I will work on using ItemsControl.

ItemsControl does not work with virtualization, but the rest of the operation is as desired. I will consider the ItemsRepeater issue after I have more knowledge of Avalonia myself. Or I will implement a panel that virtualization works.

Avalonia.Behaviors was my first attempt at using Avalonia. I myself am an experienced WPF user and tried to handle this with DataTriggerBehavior, but had the same problem.

Thank you again for your help.

from avalonia.controls.itemsrepeater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.