private void SpeakerContentPresenter_Loaded(object sender, RoutedEventArgs e) { ContentPresenter contentPresenter = (ContentPresenter)sender; contentPresenter.Loaded -= SpeakerContentPresenter_Loaded; AirPlaySpeakerControl control = contentPresenter.FindVisualChild<AirPlaySpeakerControl>(); if (control == null) return; _currentSpeakerControls.Add(control); control.SetSingleSelectionMode(_singleSelectionModeEnabled, false); }
/// <summary> /// If the content is an Image, don't allow scaling beyond the natural pixel dimensions of the image. /// </summary> /// <returns>The max scale, based on the pixel dimensions of any nested image.</returns> private double GetMaxScale() { if (_content == null) { return(MaximumScaleFactor); } Image image = _content.FindVisualChild <Image>(); if (image == null) { return(MaximumScaleFactor); } BitmapSource source = image.Source as BitmapSource; if (source == null) { return(MaximumScaleFactor); } return(Math.Max(1, MaximumScaleFactor * Math.Min(source.PixelWidth / image.ActualWidth, source.PixelHeight / image.ActualHeight))); }