Hi Everyone,
I would like to measure the view (generic) loaded in the DataTemplate in Xamarin Forms. For example, if I load an Grid (with multiple children) inside the DataTemplate, I would like to know the actual size of the Grid to layout it in the view.
Code Example:
var datatemplate = new DataTemplate(() => { var grid = new Grid(); ... var nameLabel = new Label { FontAttributes = FontAttributes.Bold }; var ageLabel = new Label(); var locationLabel = new Label { HorizontalTextAlignment = TextAlignment.End }; nameLabel.SetBinding(Label.TextProperty, "Name"); ageLabel.SetBinding(Label.TextProperty, "Age"); locationLabel.SetBinding(Label.TextProperty, "Location"); grid.Children.Add(nameLabel); grid.Children.Add(ageLabel, 1, 0); grid.Children.Add(locationLabel, 2, 0); return new ViewCell { View = grid }; }); var content = (datatemplate.CreateContent() as ViewCell).View; //Now, it will get the element loaded in the data template. //How to get the actual size of this view. var size = content;
I know that, it is possible in Xamarin Forms because the Xamarin.Forms ListView with HasUnevenRows=”true” property does the same, it measures the view loaded in the DataTemplate and layout it accordingly in the View.
So, can anyone please suggest me how it can be achieved similarly in application?
Many thanks in Advance !!!
Regards,
Dinesh
In case anyone is interested a Full restart of the Mac resolved the issue. Better error handling is needed so the developer would have some idea as to what was causing the fatal error.
Hi .
There are lot of free and paid UI kits that you can use to make awesome mobile apps with xamarin forms.
Let me share some of the platforms that are offering a mobile and web app controls.
1. I personally use Synfusion because it's almost open source and also give you a code so that you can modify it according to your choice. Also they provide a Life Time Free License to smaller applications.
2. Infragistics is also a very good name when we talk about the Custom UI controls.
3. We have also a very good name when we talk about the UI producivity and that is Telerik.
4. Beside these we have few other options like Grial as mentioned above.
Heh, I figured it out. Apparently you can't "pass" styles this way. You need to use a style targeted at the custom control.
The above code works as is, but you need to create a new style
<Style x:Key="SimpleLabelEntry" TargetType="custom:LabelEntry"> <Setter Property="LabelStyle" Value="{StaticResource SimpleLabel}"/> <Setter Property="EntryStyle" Value="{StaticResource SimpleEntry}"/> </Style>
And then use it like this
<custom:LabelEntry Style="{StaticResource SimpleLabelEntry}" LabelText="Test Label" EntryPlaceholder="Test Placeholder" EntryText="{Binding TestEntry}"/>
close VS2019 and delete the content of bin and obj folders then open the project and build solution , everything will be ok
Although the original poster probably no longer needs any help with implementing NFC in Xamarin forms, many people most likely do. I recently complete a project that required reading/writing NFC capability for Android and iOS using Xamarin Forms. If anyone has any questions regarding how to implement cross-platform NFC, feel free to reply to this comment or send me a message. I realize that Plugin.NFC supports iOS and Android for both reading and writing, however it does not support all native functionality.
If you need to use a feature that is not supported by Plugin.NFC (or simply don't want to use it for other reasons) and cannot figure out how to implement it, I will try to help you as much as possible.
Nuget Xamarin.Android.Support.v7.
Super late on this, but I put my proguard.cfg file in the root of my Android project, then set the Build Action to ProguardConfiguration.
That being said, I believe that you can save this file anywhere in your project, as long as you set the correct build action.
Hope this helps!
You can specify it...
DependencyService.Get(DependencyFetchTarget.GlobalInstance)
It will default to constructing a new instance; so if you want a single instance then you have to specify GlobalInstance as above.
Add the image is in the Resources folder in your iOS project and is marked as bundled resource !!