void OnLoaded() { if (VisualTreeExHelper.FindItemsPanel(AssociatedObject) is not UniformGrid uniformGrid) { throw new Exception($"ItemsPanel must be of type {nameof(UniformGrid)}"); } this.uniformGrid = uniformGrid; AssociatedObject.PreviewKeyDown += AssociatedObject_PreviewKeyDown; }