diff --git a/samples/ControlCatalog/Converter/MathSubtractConverter.cs b/samples/ControlCatalog/Converter/MathSubtractConverter.cs index 009a56c0ec..6f3c99abe8 100644 --- a/samples/ControlCatalog/Converter/MathSubtractConverter.cs +++ b/samples/ControlCatalog/Converter/MathSubtractConverter.cs @@ -6,12 +6,16 @@ namespace ControlCatalog.Converter; public class MathSubtractConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - return (double)value - (double)parameter; + if (value is double dv && parameter is double dp) + { + return dv - dp; + } + return double.NaN; } - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotSupportedException(); } diff --git a/samples/ControlCatalog/DecoratedWindow.xaml.cs b/samples/ControlCatalog/DecoratedWindow.xaml.cs index a1383b9107..ed30b7f491 100644 --- a/samples/ControlCatalog/DecoratedWindow.xaml.cs +++ b/samples/ControlCatalog/DecoratedWindow.xaml.cs @@ -15,7 +15,7 @@ namespace ControlCatalog void SetupSide(string name, StandardCursorType cursor, WindowEdge edge) { - var ctl = this.FindControl(name); + var ctl = this.Get(name); ctl.Cursor = new Cursor(cursor); ctl.PointerPressed += (i, e) => { @@ -26,7 +26,7 @@ namespace ControlCatalog private void InitializeComponent() { AvaloniaXamlLoader.Load(this); - this.FindControl("TitleBar").PointerPressed += (i, e) => + this.Get("TitleBar").PointerPressed += (i, e) => { PlatformImpl?.BeginMoveDrag(e); }; @@ -38,12 +38,12 @@ namespace ControlCatalog SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); - this.FindControl"; - var mfxt = this.FindControl("MenuFlyoutXamlText"); + var mfxt = this.Get("MenuFlyoutXamlText"); mfxt.Text = ""; - var afxt = this.FindControl("AttachedFlyoutXamlText"); + var afxt = this.Get("AttachedFlyoutXamlText"); afxt.Text = "\n" + " \n" + " \n" + @@ -66,7 +66,7 @@ namespace ControlCatalog.Pages "\n\n In DoubleTapped handler:\n" + "FlyoutBase.ShowAttachedFlyout(AttachedFlyoutPanel);"; - var sfxt = this.FindControl("SharedFlyoutXamlText"); + var sfxt = this.Get("SharedFlyoutXamlText"); sfxt.Text = "Declare a flyout in Resources:\n" + "\n" + " \n" + diff --git a/samples/ControlCatalog/Pages/ImagePage.xaml.cs b/samples/ControlCatalog/Pages/ImagePage.xaml.cs index d8f4d6d5a2..45043aa5af 100644 --- a/samples/ControlCatalog/Pages/ImagePage.xaml.cs +++ b/samples/ControlCatalog/Pages/ImagePage.xaml.cs @@ -17,9 +17,9 @@ namespace ControlCatalog.Pages public ImagePage() { InitializeComponent(); - _bitmapImage = this.FindControl("bitmapImage"); - _drawingImage = this.FindControl("drawingImage"); - _croppedImage = this.FindControl("croppedImage"); + _bitmapImage = this.Get("bitmapImage"); + _drawingImage = this.Get("drawingImage"); + _croppedImage = this.Get("croppedImage"); } private void InitializeComponent() @@ -50,8 +50,11 @@ namespace ControlCatalog.Pages if (_croppedImage != null) { var comboxBox = (ComboBox)sender; - var croppedBitmap = _croppedImage.Source as CroppedBitmap; - croppedBitmap.SourceRect = GetCropRect(comboxBox.SelectedIndex); + if (_croppedImage.Source is CroppedBitmap croppedBitmap) + { + croppedBitmap.SourceRect = GetCropRect(comboxBox.SelectedIndex); + } + } } diff --git a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs index c329061fe3..70c7b1acb0 100644 --- a/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs @@ -24,11 +24,11 @@ namespace ControlCatalog.Pages public ItemsRepeaterPage() { this.InitializeComponent(); - _repeater = this.FindControl("repeater"); - _scroller = this.FindControl("scroller"); - _scrollToLast = this.FindControl