@@ -155,8 +155,21 @@ protected override UICollectionViewLayout SelectLayout()
155
155
156
156
var itemSizingStrategy = ItemsView . ItemSizingStrategy ;
157
157
var itemsLayout = ItemsView . ItemsLayout ;
158
-
159
- SubscribeToItemsLayoutPropertyChanged ( itemsLayout ) ;
158
+
159
+ //TODO: Find a better way to do this
160
+ itemsLayout . PropertyChanged += ( sender , args ) =>
161
+ {
162
+ if ( args . PropertyName == nameof ( ItemsLayout . SnapPointsAlignment ) ||
163
+ args . PropertyName == nameof ( ItemsLayout . SnapPointsType ) ||
164
+ args . PropertyName == nameof ( GridItemsLayout . VerticalItemSpacing ) ||
165
+ args . PropertyName == nameof ( GridItemsLayout . HorizontalItemSpacing ) ||
166
+ args . PropertyName == nameof ( GridItemsLayout . Span ) ||
167
+ args . PropertyName == nameof ( LinearItemsLayout . ItemSpacing ) )
168
+
169
+ {
170
+ UpdateLayout ( ) ;
171
+ }
172
+ } ;
160
173
161
174
if ( itemsLayout is GridItemsLayout gridItemsLayout )
162
175
{
@@ -169,10 +182,7 @@ protected override UICollectionViewLayout SelectLayout()
169
182
}
170
183
171
184
// Fall back to vertical list
172
- var fallbackItemsLayout = new LinearItemsLayout ( ItemsLayoutOrientation . Vertical ) ;
173
- // Manually setting the value to ensure the property changed event is properly wired..
174
- ItemsView . ItemsLayout = fallbackItemsLayout ;
175
- return LayoutFactory2 . CreateList ( fallbackItemsLayout , groupInfo , headerFooterInfo ) ;
185
+ return LayoutFactory2 . CreateList ( new LinearItemsLayout ( ItemsLayoutOrientation . Vertical ) , groupInfo , headerFooterInfo ) ;
176
186
}
177
187
178
188
public static void MapHeaderTemplate ( CollectionViewHandler2 handler , StructuredItemsView itemsView )
@@ -196,25 +206,5 @@ public static void MapItemSizingStrategy(CollectionViewHandler2 handler, Structu
196
206
{
197
207
handler . UpdateLayout ( ) ;
198
208
}
199
-
200
- void SubscribeToItemsLayoutPropertyChanged ( IItemsLayout itemsLayout )
201
- {
202
- if ( itemsLayout is not null )
203
- {
204
- itemsLayout . PropertyChanged += ( sender , args ) =>
205
- {
206
- if ( args . PropertyName == nameof ( ItemsLayout . SnapPointsAlignment ) ||
207
- args . PropertyName == nameof ( ItemsLayout . SnapPointsType ) ||
208
- args . PropertyName == nameof ( GridItemsLayout . VerticalItemSpacing ) ||
209
- args . PropertyName == nameof ( GridItemsLayout . HorizontalItemSpacing ) ||
210
- args . PropertyName == nameof ( GridItemsLayout . Span ) ||
211
- args . PropertyName == nameof ( LinearItemsLayout . ItemSpacing ) )
212
-
213
- {
214
- UpdateLayout ( ) ;
215
- }
216
- } ;
217
- }
218
- }
219
209
}
220
210
}
0 commit comments