UWP: webview making my app run front on startup among other apps - webview

i have changed settings for my pc for my startup folder it works in background but i want to show it in front i would like to know how can i achieve this
<Page
x:Class="UWS_FOREGROUND.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWS_FOREGROUND"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<!-- Source file is on the web. -->
<WebView DefaultBackgroundColor="Black" x:Name="webView1" Source="someUrl" />
</Page>

Related

Combining .net Maui WebView and other controlls on same Content Page

Trying to build a content Page with a WebView, DatePicker and button on the same content page. Any time I make the WebView Visible all the other controls become invisible. Have tried many variations but found this layout while googling. Worked for the author but not for me!
Not a lot of info out there on this. Would prefer to use a httpClient but the server I'm hitting requires JavaScript to be enabled. That causes a few issues!
Have tried numerous variations with no luck!
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:dxco="clr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls"
xmlns:dxcv="clr-namespace:DevExpress.Maui.CollectionView; assembly=DevExpress.Maui.CollectionView"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:models="clr-namespace:Pcal.Models"
x:Class="Pcal.Views.GetCal"
Title="GetCal">
<VerticalStackLayout Spacing="40" Padding="10" Background="white">
<VerticalStackLayout Spacing="10" >
<dxe:DateEdit x:Name="CalMonth"
PickerActiveViewType="Month"
BackgroundColor="white"
LabelText="Select Month"
LabelFontSize="18"
IsLabelFloating="False"
IsDateIconVisible="True"
ClearIconVisibility="Auto"
Margin="10"
DisplayFormat="MMMyy" UseNativePicker="true"/>
<HorizontalStackLayout HorizontalOptions="Center">
<Button Text="Get Calendar" WidthRequest="380"
HorizontalOptions="Fill"
Clicked="OnClicked"
BackgroundColor="Purple"
TextColor="White"/>
</HorizontalStackLayout>
</VerticalStackLayout>
<WebView Source="https://pilot.fedex.com"
IsVisible="true"
x:Name="PFCWV1"
HorizontalOptions="EndAndExpand"
HeightRequest="320"
WidthRequest="380"
Navigating="WebViewNavigating"/>
</VerticalStackLayout>
</ContentPage>

Xamarin iOS Shell FlyoutMenu not rendering correctly

I am using Shell in my App to handle navigation between views and its FlyoutMenu works perfectly on Android as can be seen here:
Screenshot of FlyoutMenu on Android
However, when I open the Flyout on iOS it looks completely different (and wrong):
Screenshot of FlyoutMenu on iOS
This is the code I have in my AppShell.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CMApp.AppShell"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Cargomando"
xmlns:pages="clr-namespace:CMApp"
xmlns:resources="clr-namespace:CMApp.Resources"
FlyoutBackgroundColor="LightGray">
<Shell.Resources>
<ResourceDictionary>
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader>
<Image Source="cargomando.png"/>
</Shell.FlyoutHeader>
<FlyoutItem Title="{x:Static resources:Tour.TitleString}">
<Tab>
<ShellContent>
<pages:TourList/>
</ShellContent>
</Tab>
</FlyoutItem>
<FlyoutItem Title="{x:Static resources:Settings.TitleString}">
<Tab>
<ShellContent>
<pages:Settings/>
</ShellContent>
</Tab>
</FlyoutItem>
<MenuItem Text="{x:Static resources:Footer.PrivacyProtection}" Command="{Binding PrivacyProtectionCommand}"/>
<MenuItem Text="{x:Static resources:Footer.Imprint}" Command="{Binding ImprintCommand}"/>
<MenuItem Text="DEBUG: Tracking stoppen" Command="{Binding StopTrackingCommand}"/>
</Shell>
What am I doing wrong that it works fine on Android but not on iOS? Thanks!
During creation of a sample application for Lucas Zhang I noticed that the sample application works fine. After comparing my App and the sample after some digging I noticed that the problem is caused by defining a global style for Grid in my ResourceDictionary of my App.xaml. Xamarin apparently uses a Grid for the elements in the FlyoutMenu to which my style with a pretty large HeightRequest gets applied but this seemingly only happens on iOS.

Scrolling in Xamarin Forms SfListView causes NullReferenceException in iOS Main function

I just had a very weird issue in my app.
I was adding Syncfusion's SfListView to some pages in my app and for some reason, if the first thing I do when a page that uses the SfListView loads is scroll the ListView, I get a NullReferenceException...in the UIApplication.Main() function that gets called in the iOS project's Main class. There's nothing special in that class at all, though.
It gets better. If I do something else first, like dragging and dropping the items in the SfListView to reorder them and then I scroll it, it doesn't throw the exception.
What on Earth could be causing this?
Here is the XAML for one of the pages that uses the SfListView:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:syncfusion="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
mc:Ignorable="d"
x:Class="Partylist.Views.EventsPage"
Title="Events"
BackgroundColor="White">
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="settings_gear.png"
Priority="0"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<!--Main layout of the page-->
<StackLayout>
<!--ListView of the events-->
<syncfusion:SfListView x:Name="EventsListView"
SelectionMode="Single"
SelectionGesture="Tap"
SelectionChanged="OnItemSelected"
DragStartMode="OnHold">
<syncfusion:SfListView.DragDropController>
<syncfusion:DragDropController UpdateSource="True"/>
</syncfusion:SfListView.DragDropController>
<syncfusion:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<SwipeView>
<!--Swipe from the right to make some options
appear-->
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Invoked="OnDelete"
CommandParameter="{Binding .}"
Text="Delete"
BackgroundColor="#ff418b"
IsDestructive="true"/>
<SwipeItem Invoked="OnRename"
CommandParameter="{Binding .}"
Text="Rename"
BackgroundColor="#FF7700"/>
</SwipeItems>
</SwipeView.RightItems>
<!--This is the content that actually appears-->
<StackLayout Padding="20,5">
<Label Text="{Binding EventFolder.Name}"
TextColor="#FF7700"
FontSize="Large"/>
</StackLayout>
</SwipeView>
</ViewCell>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>
</syncfusion:SfListView>
<!--"New Event" button-->
<Button Text="+ Add New Event"
TextColor="#ff418b"
FontSize="Large"
BackgroundColor="#00ffffff"
Clicked="OnNewEventClicked"/>
<!--The banner at the bottom of the screen that gives tips-->
<Frame BorderColor="#ff418b"
Padding="0"
HeightRequest="75">
<FlexLayout Direction="Row"
AlignItems="Stretch"
JustifyContent="SpaceBetween">
<!--The "Tip" icon-->
<Image Source="tip_icon.png"
Margin="10"
FlexLayout.Basis="50"/>
<!--The short version of the tip-->
<Label x:Name="tipLabel"
VerticalTextAlignment="Center"
TextColor="#bb0099"
FontSize="Medium"
FontAttributes="Bold"
FlexLayout.Basis="240"/>
<!--The button that opens up a screen
with the rest of the tip-->
<Button Clicked="OnMoreClicked"
Text="More"
TextColor="White"
FontAttributes="Bold"
FontSize="Medium"
BackgroundColor="#ff418b"
FlexLayout.Basis="100"/>
</FlexLayout>
</Frame>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Here is the iOS project's Main class:
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace Partylist.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate"); // This is the line that throws the exception.
}
}
}
UPDATE: I just applied the SfListView to a couple more pages in my project and I couldn't type into the entries in the items on those pages' lists or use their SwipeViews (the experimental ones in Xamarin, not the ones from the SfListView) without crashing the app in the same way as above.
I just got rid of the Synfcusion ListView and switched back to the one that Xamarin comes with. #BenReierson said it's a problems with Xamarin, so maybe I'll look into switching back when that bug gets fixed.
Glad to inform that the reported issue “NullReferenceException throws when scrolling the SfListView with DragDropController” has been included in Syncfusion's latest Weekly NuGet release update version 18.2.0.46 which is available for download (https://www.nuget.org/).

Banner not shown

I started to use advertising control, but I'm going crazy trying to let it work.
I copied PivotPage.xaml from Microsoft Ad Control Sample and made it the starting page in my app, but ad control is not shown (I'm not able to see banner); if I try to run Microsoft app, banner is shown.
So I registered my app on pubCenter and I got an appId and a unitId and tried to use them in my app, but the result is the same: no banner!!
If I try to use my ids in Microsoft app, test banner is shown.
Why using Microsoft example I'm able to see banner and using same page in my app I can't?
Why using my ids, Microsoft app does not show correct banner?
Here is XAML
<!--Pivot Control-->
<controls:Pivot Grid.Row="0" Title="Ad Control Sample">
<!--Pivot item one-->
<controls:PivotItem Header="piv 1">
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem Header="piv 2">
</controls:PivotItem>
<!--Pivot item three-->
<controls:PivotItem Header="piv 3">
</controls:PivotItem>
</controls:Pivot>
<StackPanel Grid.Row="1" VerticalAlignment="Bottom" >
<TextBlock Text="This is the same ad."
TextWrapping="Wrap"
HorizontalAlignment="Stretch"
TextAlignment="Center" />
<my:AdControl Name="adControl1"
ApplicationId="test_client"
AdUnitId="Image480_80"
HorizontalAlignment="Center"
Width="480" Height="80" />
</StackPanel>
I finally managed to solve my problem and I want to share solution.
I add an event handler for ErrorOccurred on ad control and reading Microsoft.Advertising.AdErrorEventArgs e I realized that my manifest (WMAppManifest.xml) was missing
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />

Silverlight Host App only showing loading image

Im attempting to use Silverlight and MVC together. After creating a simple Silverlight application I attempted to view it using the MVC host application (using the provided aspx and html pages). The issue is that when I view the page all I see is the Loading image (with a 100% value) and that is all. It never displays my app!
Here is the html for the aspx page:
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/MVCSilverlight.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40818.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
And here is the xaml for the application:
<UserControl x:Class="MVCSilverlight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="500">
<Canvas x:Name="LayoutRoot" Background="Crimson">
<TextBlock Text="Hello World" ></TextBlock>
</Canvas>
</UserControl>
Everything else in the application is standard code (code that was generated when I created the project). Has someone seen this issue before? Is there something that I'm missing? I'm very new to both technologies to any info will be very helpful.
When you run the app check that VS has attached to the browser process for Silverlight debugging (not Script).
Also check your App.xaml.cs contains:-
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}
The loading splash screen will remain in place whilst the RootVisual remains unset. So either the code just doesn't set it or an error is occuring (and for some reason your not being alerted of the error) so that code never reaches the assignment of RootVisual.
Also get yourself a the free HTTP debugging tool called Fiddler so you can trace all the actual HTTP conversations, perhaps the xap isn't being downloaded at all for some reason. In fact that would be my guess, the MVC routing might be doing something undesirable with "ClientBin/MVCSilverlight.xap".

Resources