Xamarin.Forms WindowsPhone Landscape NavigationPage shows black area - windows-phone-8.1

I have a strange behaviour in my Xamarin.Forms app on the WinPhone client.
My MainPage is a NavigationPage. And when I navigate to the second page and turn the phone to landscape (also happens on the other way), the page shows a black area on the right side. It seems that the height and width properties don't get re-calculated on the device orientation change.
To reproduce this, just create a new Xamarin.Forms Blank App (Visual Studio 2013 template), Update the Xamarin.Forms nuget to the newest verson (in my case: 2.0.0.6490), and add the following to the App-Constructor:
var second = new ContentPage
{
BackgroundColor = Color.Green,
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Second Page"
}
}
}
};
var button = new Button {Text = "Show Second"};
button.Clicked += async (sender, args) => { await ((NavigationPage) MainPage).PushAsync(second); };
var firstpage = new ContentPage
{
BackgroundColor = Color.Blue,
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "First Page"
},
button
}
}
};
// The root page of your application
MainPage = new NavigationPage(firstpage);
Is this a bug in Xamarin.Forms? Or miss I just something? Thanks in advance

I cant see any existing filed bugs on this. If it is easily reproducible as described, then create a small repro project and submit to bugzilla.xamarin.com. It will be a xf regression bug.
Thanks #Joehl - I obviously am not too great at searching bugzilla on my mobile. As mentioned this is the bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=36477

Related

.net Open link from WebBrowser Control in a new Tab in IE

I have a web browser control in my application which contains the following link:
<html>
<body>
test
</body>
</html>
Each time I click on this link, it gets opened in a new window of IE instead of a new Tab. I tried loading this html directly in IE - then it correctly gets opened in new tabs.
I have also configured the IE setting to open links in new tabs instead of new windows.
Can anyone help me out to load the links from the web browser control in a new tab?
Thank you!
It would have been helpful if you had specified whether you were using Winforms or WPF for your web browser control or even what language you were using (C#, VB,F#, etc) but assuming you are using winforms and C# this solution would work.
You simply cancel the new window event and handle the navigation and tab stuff yourself.
Here is a fully working example.
using System.ComponentModel;
using System.Windows.Forms;
namespace stackoverflow2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webBrowser1.NewWindow += WebBrowser1_NewWindow;
this.webBrowser1.Navigated += Wb_Navigated;
this.webBrowser1.DocumentText=
"<html>"+
"<head><title>Title</title></head>"+
"<body>"+
"<a href = 'http://www.google.com' target = 'abc' > test </a>"+
"</body>"+
"</html>";
}
private void WebBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true; //stop normal new window activity
//get the url you were trying to navigate to
var url= webBrowser1.Document.ActiveElement.GetAttribute("href");
//set up the tabs
TabPage tp = new TabPage();
var wb = new WebBrowser();
wb.Navigated += Wb_Navigated;
wb.Size = this.webBrowser1.Size;
tp.Controls.Add(wb);
wb.Navigate(url);
this.tabControl1.Controls.Add(tp);
tabControl1.SelectedTab = tp;
}
private void Wb_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
tabControl1.SelectedTab.Text = (sender as WebBrowser).DocumentTitle;
}
}
}

Disable Chrome paste menu on text inputs while on a touch screen

How to disable this annoying contextmenu in chrome while on a touch screen. This pops up on selection/on long tap of any input while i have some text copied.
Am developing an app using CEFSharp (Chromium Embedded Framework) and its going to be deployed on touch screen on windows 8 machine. am using a on screen keyboard(http://mottie.github.io/Keyboard/) for entering text in input fields.
I have tried
$('input').bind('copy paste contextmenu', function (e) {
e.preventDefault();
e.stopPropagation();
});
this disables the pasting but the menu still shows up. how do i get rid of this menu? how best to approch this: CSS , Javascript or through chrome command line arguments (http://peter.sh/experiments/chromium-command-line-switches/) ?
i know you said JS / CSS, but this worked for me
var browser = new ChromiumWebBrowser("http://www.afrobotics.co.za")
{
Dock = DockStyle.Fill,
DragHandler = new DragHandler(),
MenuHandler = new ContextHandler()
};
//
public class ContextHandler : IMenuHandler
{
public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
{
return false;
}
}
public class DragHandler : IDragHandler
{
public bool OnDragEnter(IWebBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return true;
}
}

Refresh an ObservableCollection when Item's property changed

I have a observableCollection which is loaded with elements and displayed on the UI .At the same time the app is downloading one Icon for each element of the observable collection.I would like to display each Icon when its download finishes...
My code is working but i guess it's not the best pratice because I bind my collection to the Ui control 2 times...I am pretty convinced that it shouldn't be necessary ...I try to implement the InotifypropertyChanged on the element's Icon property but I still have to add those lines of code to display the Icons:
listDocsLibs = new ObservableCollection<BdeskDocLib>(listBoxGetDocsLibs);
llslistDocslibs.ItemsSource = listDocsLibs;
Below the function which dowload the Icons
List<BdeskDocLib> listBoxGetDocsLibs = new List<BdeskDocLib>();
ObservableCollection<BdeskDocLib> listDocsLibs = new ObservableCollection<BdeskDocLib>();
private async void LoadIconDocLibs()
{
foreach (var doclib in listBoxGetDocsLibs)
{
byte[] Icon = await ServerFunctions.GetDocLibsIcon(doclib);
if (Icon != null)
{
{
var ms = new MemoryStream(Icon);
BitmapImage photo = new BitmapImage();
photo.DecodePixelHeight = 64;
photo.DecodePixelWidth = 92;
photo.SetSource(ms);
doclib.Icon = photo;
}
}
else if (Icon == null)
{
doclib.Icon = new BitmapImage();
doclib.Icon.UriSource = new Uri("/Images/BDocs/ico_ext_inconnu.png", UriKind.Relative);
}
}
}
//IM PRETTY SURE The following code IS NOT NECESSARY BUT WHY MY UI IS NOT REFRESHING WITHOUT ?
listDocsLibs = new ObservableCollection<BdeskDocLib>(listBoxGetDocsLibs);
llslistDocslibs.ItemsSource = listDocsLibs;
}

flex 4.6 : How to cache image captured using PersistenceManager

Im beginner in Flex mobile application , my issue is the app restart then i used PersistenceManager to solve it, but when i take an image with camera i cannot hold the image if the app restart then how to hold all image captured when user click to save button i think it will be in the imagecaptured method but it doesn't work the app restarted and camera app is opened to take image method is
public function imagecaptured(event:MediaEvent):void
{
//submitButton.enabled = false;
antherImg.label = "please wait to detect your location";
imagepromise = event.data;
imgBorder.source = imagepromise.file.url;
//values to send
var imgURL:Object = imagepromise.file.url;
var imgName:Object = imagepromise.relativePath;
//save Persistence
var saveManager:PersistenceManager = new PersistenceManager();
saveManager.setProperty("url", imagepromise.file.url);
saveManager.setProperty("name", imagepromise.relativePath);
}
and when page creation (creationComplete)
public var loadManager:PersistenceManager = new PersistenceManager();
if(loadManager.load())
{
var savedData:Object = saveManager.getProperty("url");
var savedData:Object = saveManager.getProperty("name");
}
Please help , Thanks in advance

How to add tooltip in map windows phone 8?

My windows 8 phone app programatically add an image (as a pin) to a specific coordinataion in map using mapoverlay. And now i would like to add a tooltip to the image (pin) after tapping on it. Does anyone know how to fix this?
pinIMG = new Image();
pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Assets/pin.png", UriKind.Relative));
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = pinIMG;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = new GeoCoordinate(57.724611, 12.938945);
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
MyMap.Layers.Add(myLocationLayer);
Instead of adding an Image to the MapOverlay, consider adding an ExpanderView control that expands to add additional data. You'll need to download the Windows Phone Toolkit to get the ExpanderView control. While you're at it you might want to switch over to using Map Extensions Pushpins to get databinding support.
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
MapLayer myLayer = new MapLayer();
MapOverlay myOverlay = new MapOverlay()
{
GeoCoordinate = new GeoCoordinate(-17, 133)
};
ExpanderView expander = new ExpanderView();
expander.Header = new Image()
{
Source = new BitmapImage(new Uri("Assets/ApplicationIcon.png", UriKind.Relative)),
Width = 200
};
expander.ItemsSource = new[]
{
new TextBlock{ Text = "HELLO"}
};
;
myOverlay.Content = expander;
myLayer.Add(myOverlay);
myMap.Layers.Add(myLayer);
}
When we run this sample we can see the following icon over australia:
And once we click ti we can see our "Hello" text show up:
A few ceavets: the code sample above is terrible. ExpanderView is meant to use both ItemSource and IteTemplate for multiple items databinding. Using it for a single item isn't great. The above code sample is also terrible since it creates UI elements in C# code whereas using Map Extensions could have placed this code in XAML.