Hello Guys,
I want to show a new Page by clicking the ViewDetails button not ListviewItemclicked.
I want to pass this paramter .
I want to know how to get this Data
My Coding is
Xamarin Listview button
How to implement kiosk mode for xamarin.forms application?
I have been searing to implement the kiosk mode for xamarin.forms application but could never came across any sample in the xamarin.forms, can some help me to implement kiosk for the xamarin. forms android and ios applications.
Custom View Cell: View not getting updated in case PropertyChanged event
I have a listview which consumes custom view cell.
However View is not getting updated in case of property change event is triggered .
I can see that View Model is getting updated values in case event is triggered but my View is not getting updated.
CustomViewCell.xaml:
<Label HorizontalTextAlignment="Start"
VerticalTextAlignment="End"
FontSize="16"
FontAttributes="Bold"
LineBreakMode="WordWrap"
Grid.Column="0"
Grid.Row="0"
Text="{Binding TextMain}"
x:Name="MainTitleLabel"/>
<Label HorizontalTextAlignment="Start"
VerticalTextAlignment="Center"
FontSize="14"
Grid.Column="0"
Grid.Row="1"
Text="{Binding TextDetail}"
x:Name="TextDetailLabel"/>
<Image VerticalOptions="Center"
HorizontalOptions="EndAndExpand"
HeightRequest="24"
WidthRequest="24"
IsOpaque="True"
Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
Source="{Binding ImageSource}}"
x:Name="ImageSourceLabel"/>
CustomViewCell.xaml.cs:
public CustomViewCell()
{
InitializeComponent();
}
public static BindableProperty MainTitleProperty = BindableProperty.Create(nameof(MainTitle), typeof(string), typeof(CustomViewCell));
public string MainTitle
{
get => (string)GetValue(MainTitleProperty);
set => SetValue(MainTitleProperty, value);
}
public static BindableProperty TitleDetailProperty = BindableProperty.Create(nameof(TitleDetail), typeof(string), typeof(CustomViewCell));
public string TitleDetail
{
get => (string)GetValue(TitleDetailProperty);
set => SetValue(TitleDetailProperty, value);
}
public static BindableProperty ConnectionImageSourceProperty = BindableProperty.Create(nameof(ConnectionImageSource), typeof(Image), typeof(CustomViewCell));
public Image ConnectionImageSource
{
get => (Image)GetValue(ConnectionImageSourceProperty);
set => SetValue(ConnectionImageSourceProperty, value);
}
protected override void OnBindingContextChanged()
{
MainTitleLabel.Text = MainTitle;
DetailLabel.Text = TitleDetail;
ImageSourceLabel.Source = ConnectionImageSource.Source;
base.OnBindingContextChanged();
}
CustomViewCellViewModel .cs:
public class CustomViewCellViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
private string _mainTitleText = null;
public string MainTitleText
{
get { return _mainTitleText; }
set
{
if (_mainTitleText == null || !_mainTitleText.Equals(value))
{
_mainTitleText = value;
OnPropertyChanged("MainTitleText");
}
}
}
private string _titleDetailText = null;
public string TitleDetailText
{
get { return _titleDetailText; }
set
{
if (_titleDetailText == null || !_titleDetailText.Equals(value))
{
_titleDetailText = value;
OnPropertyChanged("TitleDetailText");
}
}
}
private string _imageSource = null;
public string ImageSource
{
get { return _imageSource; }
set
{
if (_imageSource == null || !_imageSource.Equals(value))
{
_imageSource = value;
OnPropertyChanged("ImageSource");
}
}
}
How to put ellipsis for long text in Picker?
How to put ellipsis for long text in Picker?
Prevent fitting content of Swipe to reveal Grid's view
I've created a grid consisting of two columns and one row. At the initial state, the left column width is 0* and the right is 100*. I wrote a custom renderer for the grid and overrode OnTouchEvent to make the grid swipeable by changing the grid's columns' width when I swipe to right. I added this custom grid as a DataTemplate of a ListView to give the swipe to reveal effect for each element.
The problem is, when the columns' width are changed, the views inside the right column fills the space instead of going outside the visible screen as expected. For example, when I swipe right the labels inside the right column begin to fit the space that's getting smaller instead of staying in place and going outside the screen's boundaries. How can I prevent this behavior?
Maybe even a more important question, should I use another layout for swipe to reveal behavior?
How to handle notification click on Xamarin form ios project
When my Xamarin ios app is in background and I am clicking on the Push notification it is always opening the page i.e in background. Please let me know how I can open another app page on clicking push notifications. when I am clicking on notification public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action completionHandler)
{
}
event is called but I am not able to redirect to another app page.
Custom Renderer for tabs at the bottom of the page + icon font -> Icons invisible at clicking a tab?
Hey there,
in my project, I am trying to display tabs at the bottom of the page, as well as on Android as on iOS.
I found out that I can achieve it by adding this line to the xaml.cs:
On().SetToolbarPlacement(ToolbarPlacement.Bottom);
In addition, I want to use icon font for the tab's icons. Therefor, I'm using the FlatTabbedRenderer from this post/example:
(For some reason, I am not able to post the link)
The first problem was, that the example renderer works with TabLayout to set the new drawable icon to it. But when I use toolbar placement at the bottom, the tab elements are not TabLayout elements any more, they are changed to BottomNavigationItemView.
So I had difficulties to address the correct view to change the icons, and I had no idea, which one is the correct Resource Id of the BottomNavigation.
I solved this by writing a workaround, which iterates through all views of the RootView and returns the one of type "BottomNavigationItemView".
Then I changed the UpdateTabbedIcons method to work with those menu items, and everything is fine....
...... until I click one of the tabs. Then, for any reason, the icons of all tabs are not visible anymore.
Has anyone an idea, why the tab's text and icon are disappearing on click?
I will try to upload a sample project that shows this behaviour.
Thanks in advance!
CrossMedia works in Debug but not in Release for UWP - error msg about onecore(??)
Below is a snippet of my code. Each of the Debug.WriteLine output that starts with a "->" is to indicate the echoing of what code is about to be run. That is followed by an error message that the system produces that starts with either "onecore" or "onecoreuap". In this way it is easy to see the code and the message that it produces.
I looked up onecoreuap and this MS site
https://msdn.microsoft.com/en-us/library/windows/desktop/mt654040%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
indicates that "OneCoreUap.lib ... provides the exports for the subset of Win32 APIs that are common to all Windows 10 devices that support the Universal Windows Platform (UWP)."
However, a note at the end says:
"**Important **Windows Store apps should not use OneCoreUap.lib but need to use WindowsApp.lib instead."
1) how can I fix this?
2) how does that app get access to "onecore" or "onecoreuap" (when I do not want it and did not ask for it)?
3) how do I link in to "WindowsApp.lib instead" or do I even need it? (I tried through references in the UWP project)
Here is my code:
`
Debug.WriteLine("->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions");
mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small,
});
IFolder baseFolder = FileSystem.Current.LocalStorage;
IFolder picFolder = null;
// The following gets a path for the folder to contain the picture
picFolder = await Util.GetPicPath(baseFolder);
Debug.WriteLine("->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);" );
IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);
newFilePath = newFile.Path;
Debug.WriteLine("->using (Stream sWriter = mediaFile.GetStream())");
using (Stream sWriter = mediaFile.GetStream())
{
Debug.WriteLine("-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))");
using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
{
Debug.WriteLine("->await sWriter.CopyToAsync(stream);");
await sWriter.CopyToAsync(stream);
}
}
//==================================
`
Here is the output that I get:
pickPhoto
->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(5) tid(59b4) 80040154 Class not registered
->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);
onecoreuap\shell\windows.storage\dataaccess.cpp(4237)\windows.storage.dll!74610A1F: (caller: 746106BB) ReturnHr(1) tid(5904) 80004001 Not implemented
->using (Stream sWriter = mediaFile.GetStream())
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(2) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(6) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(7) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(8) tid(65b0) 80040154 Class not registered
-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(3) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(9) tid(65b0) 80040154 Class not registered
->await sWriter.CopyToAsync(stream);
Done pickPhoto
Environment:
Visual Studio 2017 v 15.5.4
Xam.Plugin.Media v 3.1.3
Xamarin.Forms v 2.4.0.280 (because I can not get the app to work with higher versions yet)
Xamarin.FFImageLoading v2.3.4
and many more plugins.
Any suggestions and insight are much appreciated.
Regards, Will
iOS SKPaymentTransactionObserver method
I'm trying to add the App Store Promotion where you can submit a 1024*1024px image to a inapp purchase. And then it will display on app store and such. This requires:
These in-app purchases can’t be promoted on the App Store because your latest approved binary doesn’t include the SKPaymentTransactionObserver method.
And then it links me to this: https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue
I already have the CrossInAppBilling stuff done. But this is something else and I cant seem to find any examples for it. It wants me to use the StoreKit reference from my .iOS project but thats about as much as I understand. Any suggestions, url or anything would be appreciated.
No template to add Class to Xamarin Forms ios project
I have added a new xamarin forms project on visual studio 2017 community version. I want to add a class in ios project but there is no template to add class. I had same issue with my previous project. I am unable to add class file to ios project.
DisplayActionSheet is not showing up when using Xmarin.Forms Embedded
DisplayActionSheet is not showing when I use Xamarin.Forms Embedded.
Please note that I was able to observe this feature working on a sample app (non Xamarin.Forms Embedded).
However, this feature just isn't working for me on a more involved application that relies on Xamarin.Forms embedded by use of Android Fragments.
I verified that I'm using it on a ContentPage that's the application's main page.
Website App Blocker
Create a custom animation to fade-out view in forms
Hey, sorry if this was asked before, i couldn't find any threads wich could help me.
I want to animate an element like this. It should set the opacity to 0, but not for the whole view. Instead i want the view going transparent from the center to the edge. I am using Xamarin Forms 3.4.0.1008975 and am developing for iOS and Android.
Can somebody help me with that?
Thanks
'CarouselView' exists in both 'Xamarin.Forms.CarouselView' and 'Xamarin.Forms.Core'
I have issue with carouselview. after installing CarouselView from NuGet Manager giving me below error.
The type 'CarouselView' exists in both 'Xamarin.Forms.CarouselView, Version=1.0.0.0' and 'Xamarin.Forms.Core, Version=2.0.0.0
Using IsDescructive in ContextAction produces non clickable items on iOS
Hello,
I have a listview with uneven rows. The items have a typical context action "delete" with the attribute "IsDescructive="true". Now, when I swipe on an item to open the context menu and then cancel the action, the item is not clickable anymore until the listview is realoaded completely.
This is XAML code of my listview:
<ListView x:Name="listView" Margin="0,0,0,0" HasUnevenRows="True" SelectionMode="None" ItemTapped="ListView_ItemTapped" ItemAppearing="ListView_ItemAppearing" BackgroundColor="{StaticResource StandardBackgroundColor}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Clicked="OnDelete" CommandParameter="{Binding .}" Text="Löschen" />
</ViewCell.ContextActions>
<StackLayout Orientation="Vertical" HeightRequest="90" HorizontalOptions="Fill">
<StackLayout Orientation="Horizontal" Margin="10,10,10,0" HorizontalOptions="Fill">
<Label Text="{Binding Discipline}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" FontSize="Small" FontAttributes="Bold" TextColor="Black" MaxLines="1"/>
<Label Text="{Binding Startdate}" VerticalOptions="Center" HorizontalOptions="End" FontSize="Small" MinimumWidthRequest="100" HorizontalTextAlignment="End" MaxLines="1"/>
</StackLayout>
<StackLayout Orientation="Horizontal" Margin="10,0,10,0" HorizontalOptions="Fill" >
<Label Text="{Binding FinalResult}" VerticalOptions="Center" HorizontalOptions="Start" WidthRequest="50" MinimumWidthRequest="50" FontSize="Medium" TextColor="{StaticResource ColorPrimary}" FontAttributes="Bold"/>
<Label Text="{Binding PartResults}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" FontSize="Small"/>
</StackLayout>
<StackLayout Orientation="Horizontal" Margin="10,0,10,10" HorizontalOptions="Fill">
<Label Text="{Binding ActivityType}" VerticalOptions="Center" HorizontalOptions="Start" FontSize="Small" TextColor="Gray" FontAttributes="Bold"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
In the ItemAppearing event I load the model from the database to set the labels via the viewmodel.
The listview ItemSource is set in the constructor of the page and the type is ObservableCollection. So not something special.
As soon as I remove the IsDestructive attribute from the MenuItem, everything works well.
Does someone also have the problem?
Is it possible to wait for Device.BeginInvokeOnMainThread code to finish
Hello everyone,
In my code I have a task called "ShowMessageBoxAsync". I want to use this code to show (and await) the DisplayAlert to the user and return the result. Like this: var messageBoxResult = await View.ShowMessageBoxAsync("This is an error");
The code for the ShowMessageBoxAsync is:
public async System.Threading.Tasks.Task<bool> ShowMessageBoxAsync(string message)
{
var result = false;
Device.BeginInvokeOnMainThread(async () =>
{
result = await DisplayAlert("Error", message, "OK", "Cancel");
});
return result;
}
Before I added the Device.BeginInvokeOnMainThread, the task gave me an Exception that it wasn't running on the main/UI thread. So after adding BeginInvokeOnMainThread, it started to work without exceptions. The problem, however, is that the code goes directly to the result, without waiting for the result of the "await DisplayAlert".
Is it possible return the value of "result" only after the Device.BeginInvokeOnMainThread code finishes?
Thanks in advance!
Exception Unhandled when selecting a page from Master Deatail Nav Template
Hi I am trying to load a JSON file when I go to a page on my app but when I select the page using the Master Detail Page Navigation template it throws this error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
which the code its highlighting is in the MainPage.xaml.cs:
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
In my LoadJson class it happens just after the Using line:
`public void LoadJson()
{
//Loads the JSON File in the Solution and Finds Correct ID of Accordion Hopefully!!
var assembly = typeof(App).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream("MasterDetailPageNavigation.TimeSheet.json");
string jsonString = "";
using (var reader = new StreamReader(stream))
{
jsonString = reader.ReadToEnd();
};
uoObj = JsonConvert.DeserializeObject<RootObject>(jsonString);
}`
the JSON is in the root of my PCL so i believe the above is correct. can anybody help
How to set ContentPage's Background color ?
Hi !
Anyone know how can i set the background color of my content page ?
Thanks !
Implementing Bluetooth features to Print on a bluetooth printer in Xamarin Forms App
I'm trying to avail Bluetooth features in my Xamarin Forms App to Print on a bluetooth printer but can't get it working.
Even not able to search devices and pair.
I tried below two plugins but none of them works for me.
I tried this example as well:
https://julianocustodio.com/2017/12/07/bluetooth/amp/?__twitter_impression=true
Does anyone have working example?
Any help is much appreciated.
Thanks
Using a dictionary with 10,000 values gives an error
Hi,
I am building an android app to build a puzzle from some pre-loaded puzzles in a dictionary variable (of int, string). It has over 12,000 puzzles. When the user clicks new game, a random integer is generated and the corresponding puzzle is selected from dict and loaded.
When the dict had only 10 puzzles app was working fine, but the moment I added 10,000 puzzles it shows an error the method playgame():ctor (int) is too complicated.
So I guess it has something to do with the dictionary variable? Each item has atleast 2000 characters.
Can someone tell me why this is happening and how to avoid this? I don't want to use SQlite . Can i store these puzzles in application resources and then load them?
Regards,