I'm testing out Xamarin Forms's new Platform-Specifics features (in 2.3.3). In particular, the EnableTranslucentNavigationBar.
I have a RootPage object that is a MasterDetail. The Detail is a NavigationPage. Here's my relevant App() ctor code:
public App()
{
InitializeComponent();
//Note: RootPage is MasterDetail, Detail is NavigationPage
var rootPage = new RootPage();
(rootPage.Detail as NavigationPage).On<iOS>().EnableTranslucentNavigationBar();
MainPage = rootPage;
}
This however is not applying the translucent navigation bar effect on the NavigationPage. It is still a solid color (default white) and the content doesn't scroll up
Is there a specific place/time I need to apply this?
Side Note: While working on this, I also noticed a weird ambiguity between two different NavigationPage objects. One in Xamarin.Forms.NavigationPage and one in Xamarin.Forms.PlatformConfiguration.iOSSpecific.NavigationPage. I eventually got the method to use the former, but it made me think that I might need to cast it first...
UPDATE:
Xamarin reports this should be fixed in 2.3.4-pre1
Xamarin has confirmed this is an issue in Xamarin.Forms 2.3.3 and are investigating. Go here to see the Bugzilla report.
I will update this post once I hear back from them regarding a fix or workaround.
UPDATE
Should be fixed in 2.3.4-pre1
Related
Having experiences various forms of flickering and graphical glitches, I searched online for possible solution. The only thing that worked straight away was accepted solution using NativeWinAPI from post just below:
Avoid Flickering in Windows Forms?
Inserting this code in the main form of the application and keeping handle for 'this' practically eliminated every issue I had with graphics.
At least until I included a web browser (WebView2 Control). This control along side with the code from the post causes the control itself to constantly repaint itself. This in turn causes graphical issues within entire User Control that is parent to the WebView2. Other controls flicker in and out, which is super annoying and unpleasant.
Having spent hours(days really) trying to figure out what is wrong and practically rewriting entire project, the issue was located and it disappears straight after disabling function that sets the window style.
I am fairly certain that WebView2 Control is the only control having issues as I created OnPaint functions that write to console every time that the control was repainted, and disabling webview2 stops other controls from being repainted, while when enabled I get 100's of repaints within few seconds.
The problem is that disabling those changes makes the application look even worse with all the flickering and graphical glitches that it was fixing before.
I do not understand what the code from the link exactly does (too advanced/complex for my current knowledge). If anyone could help me figure out how to solve the issue I would really appreciate it.
Update:
I created a small demo project for anyone interested in addressing this.
It is a 7zip of the project placed on google drive:
FlickeringDemo.7z
Microsoft Edge Canary Browser is required for WebView2 to work correctly:
Download Edge Canary Here
Main form has bool flag that control graphical improvements and flickering. Simply set it to true/false to observe the difference.
Debug.WriteLine(); - will output Paint Event counter into console in Visual Studio.
bool FlickerEnabled = false;
public MainForm()
{
InitializeComponent();
if (FlickerEnabled)
{
InitialiseGraphicalFixes();
}
}
I was having the same problem in my project and I've managed to solve it.
In the provided FickeringDemo.zip sample, to stop flickering with that version of WebView2 (1.0.664.37) you should set to true the DoubleBuffered property in all of your .Net Controls; see code below for an example on how to do it.
Another thing that I've found is that this fix stops to working in WebView2 1.0.774.44; in that version the rest of your controls will not flick, but the WebView2 will flick a lot. I didn't find a way to solve it...
public partial class WebViewControl : UserControl
{
...
public WebViewControl()
{
...
//the fix to solve flicker if the WS_EX_COMPOSiTED is set on the top window
SetDoubleBuffered(this, true);
}
private void SetDoubleBuffered(Control control, bool value)
{
try
{
control.GetType().GetProperty("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(control, value, null);
}
catch
{
}
foreach (Control child in control.Controls)
{
SetDoubleBuffered(child, value);
}
}
Using Xamarin Forms 2.5.0.122203, I want to achieve to add an image that is half over navigation bar and another half in the page like this image
I tried Negative margin and it only worked on UWP. Unfortunately, iOS and Android cut image.
I was thinking of creating a custom navigation bar but the thing is UWP has this bug that doesn't hide native Navigation right.
Any solution?
Thank you
I ended up Copying SNavigation.Forms to my projects.
After following their documentation.
In the Page I override
protected override void OnBindingContextChanged()
{
if (BindingContext == null)
{
return;
}
base.OnBindingContextChanged();
SNavigationPage.SetNavContent(this, new LogoHeader()
{
BindingContext = BindingContext,
});
}
The LogoHeader is the intended layout to be postioned in the Navigation (Better use a Grid)
Visually I have one Navigation Header but technically it is cut in half.
It took a lot of time to get the perfect result because you have to remove all navigation shadows from Android and iOS but it is a reliable solution
I have a scrollView with a Grid inside which contains several Entrys.
When I click anywhere on the screen that isn't one of the Entry controls the focus automatically goes to the first Entry I have on the grid. I.e. This happens whether any Entry already has Focus or not, it will always set the focus of the first one again.
If I remove the Scrollview and have the Grid on screen on it's own I don't get this issue.
I am developing an application for a Windows 10 device but using the Xamarin forms cross platform code as we may move the code to Android at some stage.
Thanks in advance.
I was able to reproduce the described behavior on UWP Windows 10, but not on Android or iOS, so this is a bug in the Forms code for UWP.
I have filed a bug report for this issue which you can track here: https://bugzilla.xamarin.com/show_bug.cgi?id=52613
Xamarin engineers will now discuss this issue on the bug report. If you would like to receive a notification when the bug is updated, you can add yourself to the CC list for the bug. Please note that you will need to create an account on that system if you have not already done so.
I don't know if you solved your problem because it was more than a year ago and the issue #jgoldberger has opened on Xamarin's Bugzilla did not progress since last October.
Nevertheless I just noticed the same behaviour on my UWP app and after looking around the internet I found a solution.
If you look at this thread : Why does my TextBox get focused when clicking inside of ScrollViewer?
Then it is easy to imagine a solution for a Xamarin.Forms app by creating a custom renderer inside your UWP project.
You can use the following code which is working perfect for me :)
using {your_project_namespace}.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
[assembly: ExportRenderer(typeof(ScrollView), typeof(ScrollViewCustomRenderer))]
namespace {your_project_namespace}.UWP
{
public class ScrollViewCustomRenderer : ScrollViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ScrollView> e)
{
base.OnElementChanged(e);
if (Control == null)
return;
Control.IsTabStop = true;
}
}
}
Hope this helps.
Cheers
Is there support in XAML in Xamarin Forms for creating a Navigation Bar for iOS? I searched in all Xamarin support, forums and internet..
At this point I am not convinced that there is support but I really don't want to re-invent the wheel if it's already invented..
Edit:
By navigation bar I mean this thingie:
When you create your pages using NavigationPage, Xamarin.Forms automatically creates a navigation bar on iOS. You can also modify quite a few things of the navigation bar, like this:
NavigationPage.SetBackButtonTitle(this, ""); // Empty text
NavigationPage.SetHasBackButton(this, false); // No back button
NavigationPage.SetTitleIcon (this, someIcon); // Set the icon
Take a look at the following article for quite a good explanation of differences between ContentPage and NavigationPage: Xamarin.Forms Pages: ContentPage and NavigationPage
Xamarin's official documentation also covers the navigation quite well: Hierarchial Navigation
Have you set your root page to be of type NavigationPage? In your App class you should have something like
MainPage = new ContentPage(); // etc.
Change it to be something like this
MainPage = new NavigationPage(new FirstPageOfTheApp());
//FirstPageOfTheApp should be of type ContentPage.
So to sum it up, the root page needs to be NavigationPage and all the other pages of type ContentPage.
actually i am developing a universal app for Windows and Windows Phone.
Within that app i am using dependency properties to assign data to properties of custom user controls in XAML. The problem is that the compiler says he is not able to find the property were i would like to bind data to.
The button definition looks like the following.
public sealed partial class RulerButton : UserControl
{
public static readonly DependencyProperty BackendProperty =
DependencyProperty.Register("Backend", typeof(GlobalData),
typeof(RulerButton), new PropertyMetadata(null));
public GlobalData Backend
{
get { return (GlobalData)GetValue(BackendProperty); }
set { SetValue(BackendProperty, value); }
}
public RulerButton()
{
this.InitializeComponent();
}
}
I use this button within my main page like this.
<btn:RulerButton Backend="{Binding ElementName=root, Path=BackendSource}"/>
Then the compiler says Unknown Member "Backend" in Element "RulerButton".
If have used the same approach earlier in other projects (Normal WPF-Windows applications) and it worked well. So i think the problem is related to universal app projects.
All other questions i have found could not solve my problem.
I would be appreciated if someone could give me a hint.
greets
Edit
Well i actually have solved the problem. But i think it is very curious. Beside the RulerButton i have many other controls where i added the same dependency properties. On some of them i did not add the normal property Backend yet. Cause i first wanted to make the RulerButton work. After completing these controls so that each of them has a BackendProperty and Backend attribute, all errors were gone.
anyway thanks for your help guys
Well i actually have solved the problem. But i think it is very curious. Beside the RulerButton i have many other controls where i added the same dependency properties. On some of them i did not add the normal property Backend yet. Cause i first wanted to make the RulerButton work. After completing these controls so that each of them has a BackendProperty and Backend attribute, all errors were gone.