Comments (5)
As a workaround: would a Converter help you instead of two DataTemplates?
from avalonia.controls.itemsrepeater.
@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.
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.
Related? #6
from avalonia.controls.itemsrepeater.
@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)
- WrapLayout caching incorrect when source collection is changed HOT 1
- Enabling WrapLayout in ControlCatalog crashes the app
- Problem with bringing items in to view in the Items Repeater. HOT 3
- ItemsRepeater's child not found in its Children collection exception
- ItemsRepeater in ScrollViewer - scroll resets to 0 on app lags when scrolling HOT 1
- Segmentation Fault when Using an ItemsRepeater in a Scrollviewer HOT 10
- First slider value always 0,when binding ObservableCollection to ItemsRepeater.
- ItemsRepeater Becomes Desynchronized With Items After Item Sort HOT 3
- ItemsRepeater inside of Viewbox leads to invisible items HOT 2
- ItemsRepeater poor performance with nested items repeaters
- ItemsRepeater doesn't show items after maximizing window HOT 3
- ItemsRepeater has incorrect render result when scroll back to previous contents HOT 1
- ItemsRepeater shows the wrong item location when the data volume is large HOT 1
- ItemsRepeater extremely slow HOT 7
- `ItemsRepeater` inside `ScrollViewer`, DataContext inconsistencies HOT 3
- [11 Nightly] :nth-last-child(1) Only evaluated once at runtime HOT 4
- Keyboard navigation issues when using ItemsRepeater
- Item Repeater WrapLayout Throws HOT 1
- ItemsRepeater not updating correctly after remove items from ObservableList HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalonia.controls.itemsrepeater.