--- /dev/null
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve (AllMembers=true)]
+ [Issue (IssueTracker.Github, 7505, "Icons from Toolbaritem are not displayed on UWP if starts on second monitor", PlatformAffected.UWP)]
+ public class Issue7505 : MasterDetailPage
+ {
+ public Issue7505()
+ {
+ Master = new ContentPage { Title = "master" };
+ Detail = CreateDetailPage("Don't look here, look at the toolbar!");
+ }
+
+ static Page CreateDetailPage(string text)
+ {
+ var page = new ContentPage {
+ Title = text,
+ Content = new StackLayout {
+ Children = {
+ new Label {
+ Text = "Pre-req: Have a multi-monitor setup with different resolutions. Then, start this app, drag it onto the secondary monitor and keep restarting it until you see the toolbar icons disappear. If they don't disappear, this works! Yes, it's a fun one.",
+ VerticalOptions = LayoutOptions.CenterAndExpand,
+ HorizontalOptions = LayoutOptions.CenterAndExpand,
+ }
+ }
+ }
+ };
+
+ var tbiBank = new ToolbarItem { Command = new Command (() => { }), IconImageSource = "bank.png" };
+ var tbiCalc = new ToolbarItem { Command = new Command (() => { }), IconImageSource = "calculator.png" };
+ var tbiXam = new ToolbarItem { Command = new Command (() => { }), IconImageSource = "xamarinlogo.png" };
+ var tbiXamSecondary = new ToolbarItem { Command = new Command (() => { }), IconImageSource = "xamarinlogo.png", Order = ToolbarItemOrder.Secondary };
+ var tbiCalcSecondary = new ToolbarItem { Command = new Command(() => { }), IconImageSource = "calculator.png", Order = ToolbarItemOrder.Secondary };
+
+
+ page.ToolbarItems.Add (tbiBank);
+ page.ToolbarItems.Add (tbiCalc);
+ page.ToolbarItems.Add (tbiXam);
+ page.ToolbarItems.Add (tbiXamSecondary);
+ page.ToolbarItems.Add (tbiCalcSecondary);
+
+ return new NavigationPage (page);
+ }
+ }
+}
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewGroupTypeIssue.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Issue7505.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CollectionViewItemsSourceTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1455.xaml.cs">
<DependentUpon>Issue1455.xaml</DependentUpon>
using System;
-using Windows.UI.Xaml.Controls;
namespace Xamarin.Forms.Platform.UWP
{
{
public object Convert(object value, Type targetType, object parameter, string language)
{
- // TODO: investigate whether we can use AsyncValue<T> instead of blocking
-
if (value is ImageSource source)
return source.ToWindowsIconElement();
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Media.Imaging;
using Xamarin.Forms.Internals;
using NativeAutomationProperties = Windows.UI.Xaml.Automation.AutomationProperties;
+using WImage = Windows.UI.Xaml.Controls.Image;
namespace Xamarin.Forms.Platform.UWP
{
Page _currentPage;
readonly NavigationModel _navModel = new NavigationModel();
readonly ToolbarTracker _toolbarTracker = new ToolbarTracker();
+ readonly ImageConverter _imageConverter = new ImageConverter();
readonly ImageSourceIconElementConverter _imageSourceIconElementConverter = new ImageSourceIconElementConverter();
Windows.UI.Xaml.Controls.ProgressBar GetBusyIndicator()
{
var button = new AppBarButton();
button.SetBinding(AppBarButton.LabelProperty, "Text");
- button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter);
+
+ if (commandBar.IsDynamicOverflowEnabled && item.Order == ToolbarItemOrder.Secondary)
+ {
+ button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter);
+ }
+ else
+ {
+ var img = new WImage();
+ img.SetBinding(WImage.SourceProperty, "Value");
+ img.SetBinding(WImage.DataContextProperty, "IconImageSource", _imageConverter);
+ button.Content = img;
+ }
+
button.Command = new MenuItemCommand(item);
button.DataContext = item;
button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId);