Skip to content

Commit

Permalink
Fix division by zero (microsoft#1366)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
Fix division by zero exception when the window is too narrow.

## Motivation and Context
Fixes microsoft#1365 

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
hez2010 committed Sep 27, 2023
1 parent cbfc1fb commit 1fcd8ed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion WinUIGallery/ControlPages/AnnotatedScrollBarPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//
//*********************************************************

using System;
using System.Collections.ObjectModel;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
Expand Down Expand Up @@ -181,7 +182,7 @@ private string GetItemColor(int itemIndex)

private int GetItemsPerRow()
{
return (itemsRepeater == null || itemsRepeater.ActualWidth == 0) ? 1 : (int) (itemsRepeater.ActualWidth / ItemWidth);
return (itemsRepeater == null || itemsRepeater.ActualWidth == 0) ? 1 : (int) Math.Max(itemsRepeater.ActualWidth / ItemWidth, 1);
}
}
}

0 comments on commit 1fcd8ed

Please sign in to comment.