Title = "Test";
BackgroundColor = Color.Pink;
Content = new Label { Text = "Hello", AutomationId ="lblHello" };
- NavigationPage.SetTitleIcon(this, "bank.png");
+ NavigationPage.SetTitleIconImageSource(this, "bank.png");
}
#if UITEST
{
ContentPage contentPage = new ContentPage();
- NavigationPage.SetTitleIcon(contentPage, "coffee.png");
+ NavigationPage.SetTitleIconImageSource(contentPage, "coffee.png");
PushAsync(contentPage);
}
navPage.BindingContext = new Issue4915ContentPage.ViewModel();
- var urlNavPage = new NavigationPage(new Issue4915ContentPage()) { Title = "nav page 1" };
+ var urlNavPage = new NavigationPage(new Issue4915ContentPage()) { Title = "nav page 2" };
urlNavPage.SetBinding(Page.IconImageSourceProperty, "ImageUrl");
urlNavPage.BindingContext = new Issue4915ContentPage.ViewModel();
+ var titleIconPage = new Issue4915ContentPage();
+ var justSetOnNavPage = new NavigationPage(titleIconPage) { Title = "nav page 3" };
+#pragma warning disable CS0618 // Type or member is obsolete
+ NavigationPage.SetTitleIcon(titleIconPage, "coffee.png");
+#pragma warning restore CS0618 // Type or member is obsolete
Children.Add(navPage);
Children.Add(urlNavPage);
+ Children.Add(justSetOnNavPage);
Children.Add(new Issue4915ContentPage() { Title = "page 2" });
Spacing = 10,
Children =
{
- CreateImageSourcePicker("Change Title Icon", getter => NavigationPage.SetTitleIcon(this, getter())),
+ CreateImageSourcePicker("Change Title Icon", getter => NavigationPage.SetTitleIconImageSource(this, getter())),
new Button
{
Text = "Page & Toolbar",
ToolbarItems.Add(new ToolbarItem { Text = "Save" });
- NavigationPage.SetTitleIcon(this, "coffee.png");
+ NavigationPage.SetTitleIconImageSource(this, "coffee.png");
SearchBar searchBar = new SearchBar { HeightRequest = 44, WidthRequest = 100 };
Text = "Toggle TitleIcon",
Command = new Command (() => {
- var titleIcon = NavigationPage.GetTitleIcon(this);
+ var titleIcon = NavigationPage.GetTitleIconImageSource(this);
if (titleIcon == null)
titleIcon = "coffee.png";
else
titleIcon = null;
- NavigationPage.SetTitleIcon(this, titleIcon);
+ NavigationPage.SetTitleIconImageSource(this, titleIcon);
})
},
new Button {
static void toggleTitleIcon(Page page)
{
- var titleIcon = NavigationPage.GetTitleIcon(page);
+ var titleIcon = NavigationPage.GetTitleIconImageSource(page);
if (titleIcon == null)
- NavigationPage.SetTitleIcon(page, "coffee.png");
+ NavigationPage.SetTitleIconImageSource(page, "coffee.png");
else
- NavigationPage.SetTitleIcon(page, null);
+ NavigationPage.SetTitleIconImageSource(page, null);
}
void masterDetailsPageIcon_Clicked(object sender, EventArgs e)
[Obsolete("Image is obsolete as of 4.0.0. Please use ImageSource instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public ImageSource Image
+ public FileImageSource Image
{
get { return GetValue(ImageProperty) as FileImageSource; }
set { SetValue(ImageProperty, value); }
public static readonly BindableProperty BarTextColorProperty = BarElement.BarTextColorProperty;
- public static readonly BindableProperty TitleIconProperty = BindableProperty.CreateAttached("TitleIcon", typeof(ImageSource), typeof(NavigationPage), default(ImageSource));
+ public static readonly BindableProperty TitleIconImageSourceProperty = BindableProperty.CreateAttached("TitleIconImageSource", typeof(ImageSource), typeof(NavigationPage), default(ImageSource));
+
+ [Obsolete("TitleIconProperty is obsolete as of 4.0.0. Please use TitleIconImageSourceProperty instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty TitleIconProperty = TitleIconImageSourceProperty;
public static readonly BindableProperty TitleViewProperty = BindableProperty.CreateAttached("TitleView", typeof(View), typeof(NavigationPage), null, propertyChanging: TitleViewPropertyChanging);
return (bool)page.GetValue(HasNavigationBarProperty);
}
- public static ImageSource GetTitleIcon(BindableObject bindable)
+ [Obsolete("GetTitleIcon is obsolete as of 4.0.0. Please use GetTitleIconImageSource instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static FileImageSource GetTitleIcon(BindableObject bindable)
+ {
+ return bindable.GetValue(TitleIconImageSourceProperty) as FileImageSource;
+ }
+
+ public static ImageSource GetTitleIconImageSource(BindableObject bindable)
{
- return (ImageSource)bindable.GetValue(TitleIconProperty);
+ return (ImageSource)bindable.GetValue(TitleIconImageSourceProperty);
}
public static View GetTitleView(BindableObject bindable)
page.SetValue(HasNavigationBarProperty, value);
}
- public static void SetTitleIcon(BindableObject bindable, ImageSource value)
+ [Obsolete("SetTitleIcon is obsolete as of 4.0.0. Please use SetTitleIconImageSource instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetTitleIcon(BindableObject bindable, FileImageSource value)
+ {
+ bindable.SetValue(TitleIconImageSourceProperty, value);
+ }
+
+ public static void SetTitleIconImageSource(BindableObject bindable, ImageSource value)
{
- bindable.SetValue(TitleIconProperty, value);
+ bindable.SetValue(TitleIconImageSourceProperty, value);
}
public static void SetTitleView(BindableObject bindable, View value)
[Obsolete("BackgroundImage is obsolete as of 4.0.0. Please use BackgroundImageSource instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public FileImageSource BackgroundImage
+ public string BackgroundImage
{
get { return GetValue(BackgroundImageProperty) as FileImageSource; }
set { SetValue(BackgroundImageProperty, value); }
UpdateToolbar();
else if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName)
UpdateToolbar();
- else if (e.PropertyName == NavigationPage.TitleIconProperty.PropertyName ||
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName ||
e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
UpdateToolbar();
}
void UpdateTitleIcon()
{
Page currentPage = Element.CurrentPage;
- ImageSource source = NavigationPage.GetTitleIcon(currentPage);
+ ImageSource source = NavigationPage.GetTitleIconImageSource(currentPage);
if (source == null || source.IsEmpty)
{
{
_imageSource = source;
_titleIconView.SetImageResource(global::Android.Resource.Color.Transparent);
- _ = this.ApplyDrawableAsync(currentPage, NavigationPage.TitleIconProperty, Context, drawable =>
+ _ = this.ApplyDrawableAsync(currentPage, NavigationPage.TitleIconImageSourceProperty, Context, drawable =>
{
_titleIconView.SetImageDrawable(drawable);
});
using AView = Android.Views.View;
using AMenu = Android.Views.Menu;
using AColor = Android.Graphics.Color;
+using System.Threading.Tasks;
namespace Xamarin.Forms.Platform.Android.AppCompat
{
else
{
TabLayout.Tab tab = _tabLayout.GetTabAt(index);
- _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon =>
- {
- SetTabIcon(tab, icon);
- });
+ SetTabIconImageSource(page, tab);
}
}
}
{
Page child = Element.Children[i];
TabLayout.Tab tab = tabs.GetTabAt(i);
- _ = this.ApplyDrawableAsync(child, Page.IconImageSourceProperty, Context, icon =>
- {
- SetTabIcon(tab, icon);
- });
+ SetTabIconImageSource(child, tab);
}
}
- void SetTabIcon(TabLayout.Tab tab, Drawable icon)
+ [Obsolete("GetIconDrawable is obsolete as of 4.0.0. Please override SetTabIconImageSource instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual Drawable GetIconDrawable(FileImageSource icon) =>
+ Context.GetDrawable(icon as FileImageSource);
+
+
+ [Obsolete("SetTabIcon is obsolete as of 4.0.0. Please use SetTabIconImageSource instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
+ {
+ }
+
+
+ protected virtual void SetTabIconImageSource(TabLayout.Tab tab, Drawable icon)
{
tab.SetIcon(icon);
SetIconColorFilter(tab);
}
+ void SetTabIconImageSource(Page page, TabLayout.Tab tab)
+ {
+ _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon =>
+ {
+ SetTabIconImageSource(tab, icon);
+
+#pragma warning disable CS0618 // Type or member is obsolete
+ SetTabIcon(tab, page.Icon as FileImageSource);
+#pragma warning restore CS0618 // Type or member is obsolete
+
+ });
+ }
+
void UpdateBarBackgroundColor()
{
if (IsDisposed)
if (ShouldShowActionBarTitleArea())
{
actionBar.Title = view.Title;
- _ = _context.ApplyDrawableAsync(view, NavigationPage.TitleIconProperty, icon =>
+ _ = _context.ApplyDrawableAsync(view, NavigationPage.TitleIconImageSourceProperty, icon =>
{
if (icon != null)
actionBar.SetLogo(icon);
});
- var titleIcon = NavigationPage.GetTitleIcon(view);
+ var titleIcon = NavigationPage.GetTitleIconImageSource(view);
useLogo = titleIcon != null && titleIcon.IsEmpty;
showHome = true;
showTitle = true;
{
if (icon != null)
{
- var image = GetTabViewItemIcon(icon);
+ var image = GetTabViewItemIconImageSource(icon);
if (image != null)
tvi.Image = image;
}
return tvi;
}
- protected virtual NSImage GetTabViewItemIcon(NSImage image)
+ protected virtual NSImage GetTabViewItemIcon(string imageName) => GetTabViewItemIconImageSource(NSImage.ImageNamed(imageName));
+
+ protected virtual NSImage GetTabViewItemIconImageSource(NSImage image)
{
if (image == null)
return null;
using System;
+using System.ComponentModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media.Imaging;
{
internal Thumb Thumb { get; set; }
internal Thumb ImageThumb { get; set; }
-
- public static readonly DependencyProperty ThumbImageProperty =
- DependencyProperty.Register(nameof(ThumbImage), typeof(WImageSource),
+
+ public static readonly DependencyProperty ThumbImageSourceProperty =
+ DependencyProperty.Register(nameof(ThumbImageSource), typeof(WImageSource),
typeof(FormsSlider), new PropertyMetadata(null, PropertyChangedCallback));
+ [Obsolete("ThumbImageProperty is obsolete as of 4.0.0. Please use ThumbImageSourceProperty instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly DependencyProperty ThumbImageProperty = ThumbImageSourceProperty;
+
static void PropertyChangedCallback(DependencyObject dependencyObject,
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
return;
}
- if (slider.ThumbImage != null)
+ if (slider.ThumbImageSource != null)
{
slider.Thumb.Visibility = Visibility.Collapsed;
slider.ImageThumb.Visibility = Visibility.Visible;
}
}
- public WImageSource ThumbImage
+ public WImageSource ThumbImageSource
+ {
+ get { return (WImageSource)GetValue(ThumbImageSourceProperty); }
+ set { SetValue(ThumbImageSourceProperty, value); }
+ }
+
+ [Obsolete("ThumbImage is obsolete as of 4.0.0. Please use ThumbImageSource instead.")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public BitmapImage ThumbImage
{
- get { return (WImageSource)GetValue(ThumbImageProperty); }
- set { SetValue(ThumbImageProperty, value); }
+ get { return GetValue(ThumbImageSourceProperty) as BitmapImage; }
+ set { SetValue(ThumbImageSourceProperty, value); }
}
internal event EventHandler Ready;
{
if (e.PropertyName == Page.TitleProperty.PropertyName)
UpdateDetailTitle();
- else if (e.PropertyName == NavigationPage.TitleIconProperty.PropertyName)
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName)
UpdateDetailTitleIcon();
else if (e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
UpdateDetailTitleView();
if (_detail == null)
return;
- Control.DetailTitleIcon = await NavigationPage.GetTitleIcon(GetCurrentPage()).ToWindowsImageSourceAsync();
+ Control.DetailTitleIcon = await NavigationPage.GetTitleIconImageSource(GetCurrentPage()).ToWindowsImageSourceAsync();
Control.InvalidateMeasure();
}
UpdateTitleVisible();
else if (e.PropertyName == Page.TitleProperty.PropertyName)
UpdateTitleOnParents();
- else if (e.PropertyName == NavigationPage.TitleIconProperty.PropertyName)
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName)
UpdateTitleIcon();
else if (e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
UpdateTitleView();
UpdateToolbarPlacement();
else if (e.PropertyName == ToolbarDynamicOverflowEnabledProperty.PropertyName)
UpdateToolbarDynamicOverflowEnabled();
- else if (e.PropertyName == NavigationPage.TitleIconProperty.PropertyName)
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName)
UpdateTitleIcon();
else if (e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
UpdateTitleView();
if (_currentPage == null)
return;
- ImageSource source = NavigationPage.GetTitleIcon(_currentPage);
+ ImageSource source = NavigationPage.GetTitleIconImageSource(_currentPage);
_titleIcon = await source.ToWindowsImageSourceAsync();
var button = new AppBarButton();
button.SetBinding(AppBarButton.LabelProperty, "Text");
- button.SetBinding(AppBarButton.IconProperty, "Icon", _imageSourceIconElementConverter);
+ button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter);
button.Command = new MenuItemCommand(item);
button.DataContext = item;
button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId);
if (thumbImage == null)
{
- Control.ThumbImage = null;
+ Control.ThumbImageSource = null;
return;
}
- Control.ThumbImage = await thumbImage.ToWindowsImageSourceAsync();
+ Control.ThumbImageSource = await thumbImage.ToWindowsImageSourceAsync();
}
protected override void UpdateBackgroundColor()
Background="{ThemeResource SystemControlForegroundAccentBrush}"
Style="{StaticResource SliderThumbImageStyle}"
DataContext="{TemplateBinding Value}"
- Tag="{Binding ThumbImage, RelativeSource={RelativeSource TemplatedParent}}"
+ Tag="{Binding ThumbImageSource, RelativeSource={RelativeSource TemplatedParent}}"
Height="24"
Width="24"
Grid.Row="0"
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Vertical" Name="TabbedPageHeaderStackPanel">
- <Image Name="TabbedPageHeaderImage" DataContext="{Binding Icon, Converter={StaticResource ImageConverter}}" Source="{Binding Value}" Width="16" Height="16" Visibility="Collapsed" Margin="0,12,0,0"/>
+ <Image Name="TabbedPageHeaderImage" DataContext="{Binding IconImageSource, Converter={StaticResource ImageConverter}}" Source="{Binding Value}" Width="16" Height="16" Visibility="Collapsed" Margin="0,12,0,0"/>
<TextBlock Name="TabbedPageHeaderTextBlock" Text="{Binding Title}" Style="{ThemeResource BodyTextBlockStyle}"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
-</ResourceDictionary>
\ No newline at end of file
+</ResourceDictionary>
#endif
}
+#if __MOBILE__
+ public static UIColor FromPatternImageFromBundle(string bgImage)
+ {
+ var image = UIImage.FromBundle(bgImage);
+ if (image == null)
+ return UIColor.White;
+
+ return UIColor.FromPatternImage(image);
+ }
+#endif
+
public static Color ToColor(this UIColor color)
{
nfloat red;
UpdatePrefersStatusBarHidden();
else if (e.PropertyName == LargeTitleDisplayProperty.PropertyName)
UpdateLargeTitles();
- else if (e.PropertyName == NavigationPage.TitleIconProperty.PropertyName ||
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName ||
e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
UpdateTitleArea(Child);
}
}
- public bool NeedsTitleViewContainer(Page page) => NavigationPage.GetTitleIcon(page) != null || NavigationPage.GetTitleView(page) != null;
+ public bool NeedsTitleViewContainer(Page page) => NavigationPage.GetTitleIconImageSource(page) != null || NavigationPage.GetTitleView(page) != null;
internal void UpdateBackButtonTitle(Page page) => UpdateBackButtonTitle(page.Title, NavigationPage.GetBackButtonTitle(page));
if (page == null)
return;
- ImageSource titleIcon = NavigationPage.GetTitleIcon(page);
+ ImageSource titleIcon = NavigationPage.GetTitleIconImageSource(page);
View titleView = NavigationPage.GetTitleView(page);
bool needContainer = titleView != null || titleIcon != null;