我正在研究 xamarin.forms。我需要通过左右交换或单击而不使用自定义渲染器来检测选项卡被更改的事件
我尝试了以下事件,但是在推送子页面或更改选项卡时,它在两种情况下都会触发。我怎样才能得到选项卡被更改的孤立事件
public class MyTabbedPage : TabbedPage
{
public MyTabbedPage()
{
this.CurrentPageChanged += CurrentPageHasChanged;
}
protected void CurrentPageHasChanged(object sender,EventArgs e)
{
var pages= Navigation.NavigationStack;
if (pages.Count > 0)
{
this.Title = pages[pages.Count - 1].Title;
}
else
this.Title = this.CurrentPage.Title;
}
}
Run Code Online (Sandbox Code Playgroud)
我面临的这个问题是:在下面的截图中,第 1 部分是 Homepage(title="Diary") & part2 是 Childpage(title="Homework") 当我更改标签并再次来到第一个标签时,导航栏标题将“作业”更改为《日记》(Screeshot2)
我有一个ListView, 我需要将它的原生colors(所选项目和其他项目)替换为不同的颜色。我无法找到如何做到这一点。我可以将背景颜色更改为不同的颜色(请参阅下面的代码),但我不知道如何使其表现得像普通的ListView、在选择时更改项目颜色。
这是我的代码:
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.Header>
<Grid BackgroundColor="Black">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Image Grid.Column="1" Grid.Row="1" WidthRequest="50" HeightRequest="50" HorizontalOptions="StartAndExpand" Source="Assets\logo.png" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="100">
<StackLayout Padding="15,10"
Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
BackgroundColor="{StaticResource LogoBackgroundColor}">
<Image WidthRequest="50" Source="{Binding IconSource}" />
<Label VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
Text="{Binding Title}"
FontSize="24"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud) 如何从 Google Play 商店获取最新的 Android 应用程序版本?之前曾使用下面的代码来做到这一点
using (var webClient = new System.Net.WebClient())
{
var searchString = "itemprop=\"softwareVersion\">";
var endString = "</";
//possible network error if phone gets disconnected
string jsonString = webClient.DownloadString(PlayStoreUrl);
var pos = jsonString.IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) + searchString.Length;
var endPos = jsonString.IndexOf(endString, pos, StringComparison.Ordinal);
appStoreversion = Convert.ToDouble(jsonString.Substring(pos, endPos - pos).Trim());
System.Diagnostics.Debug.WriteLine($"{currentVersion} :: {appStoreversion}");
System.Diagnostics.Debug.WriteLine($"{appStoreversion > currentVersion}");
if ((appStoreversion.ToString() != currentVersion.ToString() && (appStoreversion > currentVersion)))
{
IsUpdateRequired = true;
}
}
Run Code Online (Sandbox Code Playgroud)
& 下面的代码甚至抛出异常
var document =
Jsoup.Connect("https://play.google.com/store/apps/details?id=" + "com.spp.in.spp" + …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用 Web Api 服务。虽然它是具有注册和登录等小功能的应用程序,但发布的大小最初为 55 MB,然后我搜索了一下,然后将其缩小到 22 MB。我的设置仅为 Linking-SDk 程序集。我已经尝试了所有其他事情,例如取消选择共享运行时。选择 Pro Guard,生成一个包,所有类型的链接但没有得到预期的结果。我是否遗漏了什么或应用程序大小将是 22 MB。请提出解决方案
在我的应用 Firebase 推送通知未正确显示图标,它在通知中显示全灰色图标。我用于实现通知的代码
var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.ic_launcherLmg)
.SetContentTitle(user.Organization)
.SetSubText(user.ModuleName)
.SetContentText(user.BodyText)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent)
.Build();
Run Code Online (Sandbox Code Playgroud)
图标我SetSmallIcon(Resource.Drawable.ic_launcherLmg)在线设置。ic_launcherLmg 图标可在给定尺寸的以下文件夹中找到
应用程序以最高 8.1 API 为目标。最小 5.0 API。
推送通知截图
我有两个按钮。我想Button BackgroundColor使用Triggers当我单击第一个按钮时更改第二个,但我无法做到这一点。我正在尝试的代码
<Button Text="button 1" x:Name="btn1" HorizontalOptions="Fill">
<Button.Triggers>
<Trigger TargetType="Button" Binding="{Binding Source={x:Reference btn2} Property="IsEnabled">
<Setter Property="BackgroundColor" Value="Red"></Setter>
</Trigger>
</Button.Triggers>
</Button>
<Button Text="button 2" x:Name="btn2" HorizontalOptions="Fill" />
Run Code Online (Sandbox Code Playgroud)
我什至不知道在哪里为此编写点击事件。
在加载 时MainPage,我正在从 的构造函数推送另一个页面MainPageModel。它抛出NullReferenceException在MainPageModel。这是我的代码
MainPage 构造函数
public MainPage()
{
InitializeComponent();
Title = "MainPage";
BindingContext = new MainPageViewModel();
}
Run Code Online (Sandbox Code Playgroud)
MainPageModel 构造函数
public MainPageViewModel()
{
App.Current.MainPage.Navigation.PushAsync(new HomePage()); //Exception
//CommandMenu1 = new Command(async () => await NavigateNext());
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
在我的 Xamarin.iOS 项目中,我更新了 Firebase nuget 包,完成更新后我开始收到此代码的错误
//You'll need this method if you set "FirebaseAppDelegateProxyEnabled": NO in GoogleService-Info.plist
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
SISConst.PushInfo = new PushNotification();
SISConst.PushInfo.DeviceID = deviceToken.ToString();
NSUserDefaults.StandardUserDefaults.SetString(deviceToken.ToString(),"dToken");
#if DEBUG
Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);
#if RELEASE
Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Prod);
}
Run Code Online (Sandbox Code Playgroud)
下面的行显示错误
Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, Firebase.InstanceID.ApnsTokenType.Sandbox);
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅屏幕截图
我该如何解决这个问题?
到目前为止,我想filter在PowerShall脚本中应用多个,我只能添加单个,filter如下所示
Get-Childitem "D:\SourceFolder" -recurse -filter "*kps.jpg" | Copy-Item -Destination "D:\DestFolder"
Run Code Online (Sandbox Code Playgroud)
从上面的查询我能够复制只有一个文件kps.jpg ,从SourceFolder到DestFolder,我怎么给mupliple名称复制多个文件?
Image我在使用 Prism MVVM时遇到编译错误Tapped Binding。
找不到“Tapped”的属性、可绑定属性或事件,或者值和属性之间的类型不匹配。
这是我的代码
<Image Source="bell.png" HeightRequest="25" WidthRequest="25" x:Name="yellowBoxView"
RelativeLayout.YConstraint="{ConstraintExpression
Type=RelativeToParent,
Property=Height,
Factor=0.018,Constant=10}"
RelativeLayout.XConstraint="{ConstraintExpression
Type=RelativeToParent,
Property=Width,
Factor=0.85,Constant=15}">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="{Binding GetStaffAnnCommand}"></TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
xamarin ×8
c# ×5
xaml ×3
android ×2
firebase ×2
copy-paste ×1
data-binding ×1
ios ×1
listview ×1
mvvm ×1
powershell ×1
prism ×1
xamarin.ios ×1