Xamarin.Forms 2.1.0-pre5 Released

135

Posts

  • GertWijnaldaGertWijnalda NLMember

    @TheRealJasonSmith said:
    It means that if you do ListView.HasUnevenRows = true you can now call ForceUpdateSize on your cell which will force the cell to dynamically resize, even if it is currently visible. On some platforms this operation can be extremely expensive, so it is not dont automatically, but if you wanted to do so you could hook the MeasureInvalidated event on the Content of your ViewCell and call ForceUpdateSize in there. Again this can be extremely expensive.

    I'm trying exactly that with the new pre-3, but it doesn't seem to work on my end...

    SETUP: I have a "TextAreaCell" : ViewCell. It has a StackLayout that contains a Label, that has multi-line text. In the constructor, I hook the Label.MeasureInvalidated event to this.ForceUpdateSize(). I put the TextAreaCell in a Page that has TableView with UnevenRows = true.

    EFFECT: The TextAreaCell does not change size.

    What am I missing? Do you have a mini-example that shows this to work?

  • JKayJKay USMember ✭✭✭
    edited January 2016

    Does this bug fix:

    Fix issue where InputTransparent wasn't working correctly in iOS in some cases

    Relate to this bug (Changing input transparent does nothing on iOS)?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @DavidDancy yeah we don't like it either, and if you want to use the expression API go ahead, we wont be removing it in the 2.0 series at all, but be aware that there is nothing we can do about the iOS bloat due to AOT requirement. Without a JIT expression is extremely bloated and slow.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @JKay I imagine so without testing

    @GretWijnalda I will get an example made up

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    @GertWijnalda You said, that you do that in a TableView, but @TheRealJasonSmith said it would work in a ListView. Can this be the problem?

  • AnthonyRamirezAnthonyRamirez USUniversity ✭✭✭

    @MichaelRumpler Great write-up on modification ;)

  • @MichaelRumpler said:
    To change the BindableProperties you should just replace

    BindableProperty.Create<BindablePicker, IList>(p => p.ItemsSource, null,
    propertyChanged: OnItemsSourcePropertyChanged);

    with

    BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(BindablePicker), null,
    propertyChanged: OnItemsSourcePropertyChanged);

    The nameof here is a C# 6 feature. It gives you compile time safety for the property name. You can use that in VS2015 and I think it should work in XS too, but I'm not sure.
    Unfortunately VS2013 does not understand it. In VS2013 you have to specify a magic string "ItemsSource" and hope that you never do a typo in that name or rename the property.

    Unfortunately the propertyChanged handler (and I assume all the others too) has to be changed to non-generic value types too. In this case

    private static void OnItemsSourcePropertyChanged(BindableObject bindable, IList oldValue, IList newValue)

    becomes

    private static void OnItemsSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue)

    My bindable properties are static, so I can't use the nameof(ItemsSource) instead of p=>p.ItemSource which worked before.

    Do they need to be static? What disadvantage do I have when not using static BindableProperty ?

  • GertWijnaldaGertWijnalda NLMember

    @TheRealJasonSmith Cool, many thanks! [email protected] right in saying that it would only work in a ListView, not a TableView?

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    @BastiBrauning said:
    My bindable properties are static, so I can't use the nameof(ItemsSource) instead of p=>p.ItemSource which worked before.

    Do they need to be static? What disadvantage do I have when not using static BindableProperty ?

    Mine is also static, but it works (in VS2015).

    public static readonly BindableProperty ItemsSourceProperty =
        BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(BindablePicker), null,
            propertyChanged: OnItemsSourcePropertyChanged);
    

    If your BindableProperty is not static, then you could not do something like

    if (e.PropertyName == BindablePicker.ItemsSourceProperty.PropertyName)
    

    in a propertyChanged handler. Of course you should avoid magic strings there too.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    Fix crash when calling RemovePage on Android AppCompat

    Sweet

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Updating XS and VS to the latest stable version of Xamarin broke Forms for me when styling Android. See here and here I tried using older versions of XF with no luck. Please advise.

  • AxelCharpentierAxelCharpentier FRMember ✭✭

    @AdrianKnight Updating VS with the latest Xamain.VS broke absolutly everything for me, rolling back to Xamarin.VS 4.0.0.1717 fixed the issue

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    @AxelCharpentier How did you rollback to the previous?

  • AxelCharpentierAxelCharpentier FRMember ✭✭

    On the mac do this : https://forums.xamarin.com/discussion/13755/complete-uninstall-on-mac-help

    go to https://store.xamarin.com/account/my/subscription/downloads click on View all versions and download binaries according to https://releases.xamarin.com/stable-release-ios-9-2-xcode-7-2-support/ (that was the release that worked fine for me)
    Then uninstall xamarin on VS and reinstall this versionh ttp://download.xamarin.com/XamarinforVisualStudio/Windows/Xamarin.VisualStudio_4.0.0.1717.msi

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Thanks. How did you get the link for Xamarin.VisualStudio_4.0.0.1717.msi? I ask this because I might need to rollback again in the future when something like this happens again, so I need a way to see previous download URLs.

  • AxelCharpentierAxelCharpentier FRMember ✭✭

    I asked [email protected]
    Dont understand why they dont put this link in the dashboard download.

  • VictorHGarciaVictorHGarcia USUniversity ✭✭

    Any downloadable demo for TemplatedPages?

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    @AxelCharpentier Unfortunately, 4.0.0.1717 did not fix it for me.

  • AxelCharpentierAxelCharpentier FRMember ✭✭

    @AdrianKnight Sorry to here that... you should try to downgrad to the latest version that was working for you... I known its a pain :(

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    @BastiBrauning it is mandatory for a BindableProperty to be static if you want to set it from Xaml

  • LGMaestrelliLGMaestrelli BRMember ✭✭✭

    Any idea when this problem will be solved?

    http://forums.xamarin.com/discussion/comment/177664

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    I have a solution with 15 projects for all the different platforms. I upgraded all projects but those which target Windows 8.1. In these projects I get the following error in VS2015 Package Manager Console:

    PM> install-package Xamarin.Forms -version 2.1.0.6508-pre3
    Attempting to gather dependencies information for package 'Xamarin.Forms.2.1.0.6508-pre3' with respect to project 'GestureSample.WinStore', targeting 'Windows,Version=v8.1'
    Attempting to resolve dependencies for package 'Xamarin.Forms.2.1.0.6508-pre3' with DependencyBehavior 'Lowest'
    Resolving actions to install package 'Xamarin.Forms.2.1.0.6508-pre3'
    Resolved actions to install package 'Xamarin.Forms.2.1.0.6508-pre3'
    Removed package 'Xamarin.Forms.2.0.0.6484' from 'packages.config'
    Successfully uninstalled 'Xamarin.Forms.2.0.0.6484' from GestureSample.WinStore
    Package 'Xamarin.Forms.2.1.0.6508-pre3' already exists in folder 'D:\GestureSample_VS\packages'
    Install failed. Rolling back...
    Package 'Xamarin.Forms.2.1.0.6508-pre3 : ' does not exist in project 'GestureSample.WinStore'
    Package 'Xamarin.Forms.2.0.0.6484' already exists in folder 'D:\GestureSample_VS\packages'
    Added package 'Xamarin.Forms.2.0.0.6484' to 'packages.config'
    Executing script file 'D:\GestureSample_VS\packages\Xamarin.Forms.2.0.0.6484\tools\init.ps1'
    install-package : Failed to add reference to 'Xamarin.Forms.Core.Design'.
    At line:1 char:1

    • install-package Xamarin.Forms -version 2.1.0.6508-pre3
    • ~~~~~~~~~~~~~~
      • CategoryInfo : NotSpecified: (:) [Install-Package], Exception
      • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

    Whats strange is this line:

    Package 'Xamarin.Forms.2.1.0.6508-pre3 : ' does not exist in project 'GestureSample.WinStore'

    It has a ' : ' at the end of the package name. If course that package cannot be found because it's the wrong name.

    I could install 2.1.0.6503-pre2 without a problem.

    Did anybody else experience this and/or found a workaround?

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    Been busy with other stuff for a few days, but I can confirm that pre3 fixed my crash with the DataTemplateSelector on a grouped ListView.

  • JulienRosenJulienRosen CAMember ✭✭✭✭
    edited February 2016

    @JoeManke

    <ListView ItemTemplate=local:MyDataTemplateSelector />

    When I try this, my project doesn't even build. It says there are missing quotes. Isn't this a really bizarre format?

    Where is one supposed to actually create the DataTemplates? Is this example implying that your template should be built in code? I generally try to avoid code and use XAML whenever possible. If I define some DataTemplates in app.xaml, it doesn't seem my DataTemplateSelector class can see them. And really, I would much prefer not having to lump different templates for different views into app.xaml.

    <ListView ItemsSource="{Binding ReportFilters}"> <ListView.ItemTemplate> <selectors:ReportFilterDataTemplateSelector /> </ListView.ItemTemplate> </ListView>

    Edit: I followed this: https://forums.xamarin.com/discussion/comment/114331/#Comment_114331 to create my App.xaml.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @LGMaestrelli I dont believe that to be an issue with Forms but I have passed it up to the iOS team.

    @MichaelRumpler we are starting to believe this might be a race condition in the way powershell scripts are executed from nuget packages, we're looking into workarounds. Oddly we didn't change anything in the packaging from pre2 to pre3, just bumped the #.

    @JulienRosen you do have to define your DTS in code, it is not something you can define from XAML (by default). It is however easy to make a xaml buildable DTS, however the nature of that will also limit its usage a bit compared to building it from scratch. Your DataTemplates need not be built in code, just the selector.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    @TheRealJasonSmith

    They are not going away anytime soon, we deprecated them because their use should be heavily discouraged. That said I would be curious to know in what fashion they are essential to you as they literally just call the other API anyway.

    I presume this is simply because of the reflection required to get the name anyways, and the performance hit it incurs?

    one slick way to do it is with a R# template.

    image

  • JulienRosenJulienRosen CAMember ✭✭✭✭
    edited February 2016

    @TheRealJasonSmith I have defined a DataTemplateSelector in code. I am coming from a WPF background where you could define each template as a XAML DataTemplate as a resource of the page in which it would be shown. In the example, you have

    this.templateOne = new DataTemplate (typeof (ViewA));

    what and where is ViewA?

  • @JulienRosen implement it like so:

    class MenuItemTemplateSelector : DataTemplateSelector { public DataTemplate ItemTemplate { get; set; } public DataTemplate HeaderTemplate { get; set; } protected override DataTemplate OnSelectTemplate(object item, BindableObject container) { if (item is MainMenuHeaderItemViewModel) return HeaderTemplate; else return ItemTemplate; } }

    <ListView.ItemTemplate> <converters:MenuItemTemplateSelector> <converters:MenuItemTemplateSelector.ItemTemplate> <DataTemplate> <ViewCell> <Grid Padding="40,5,20,5"> <Label Text="{Binding Caption}" Style="{StaticResource LabelStyle}" FontSize="18" /> </Grid> </ViewCell> </DataTemplate> </converters:MenuItemTemplateSelector.ItemTemplate> <converters:MenuItemTemplateSelector.HeaderTemplate> <DataTemplate> <ViewCell> ... </ViewCell> </DataTemplate> </converters:MenuItemTemplateSelector.HeaderTemplate> </converters:MenuItemTemplateSelector> </ListView.ItemTemplate>

    Or use static resources:

    <Resources> <DataTemplate x:Key="ItemTemplate"> <ViewCell> ... </ViewCell> </DataTemplate> <DataTemplate x:Key="HeaderTemplate"> <ViewCell> ... </ViewCell> </DataTemplate> <converters:MenuItemTemplateSelector x:Key="TemplateSelector" ItemTemplate="{StaticResource ItemTemplate}" HeaderTemplate="{StaticResource HeaderTemplate}" /> </Resources>

    This is pretty much the same way you do it in WPF

  • JulienRosenJulienRosen CAMember ✭✭✭✭
    edited February 2016

    @DominikWeber ahh thank you. that makes more sense. you are essentially doing the data template selector constructor in xaml, this is where I was getting thrown off. Thank you.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @ChaseFlorell its because the iOS AOT compiler has no idea that we are just walking over the expression and not actually executing it. It inserts a massive (literally huge, you have no idea how much IL huge) interpreter for each expression in your codebase. So if you have a bunch of them for your BP's it bloats the everloving crap out of your dll.

  • @ChaseFlorell FWIW, you can use the c#6 nameof() operator to get the property name:

    public static readonly BindableProperty TestProperty = BindableProperty.Create(nameof(Test), typeof(string), typeof(DeclarerClass), null);

    Using the nameof operator you don't end up having two separate property names after refactoring.

    if (e.PropertyName == nameof(DeclarerClass.Test))

    @MichaelRumpler The latter code has two advantages:
    a) it is evaluated at compile time (like constants)
    b) it also works with interfaces, if you use DeclarerClass.TestProperty.PropertyName you have to have a hard reference to the implementation class

    @TheRealJasonSmith Did you already have time to take a look at the PM i sent you regarding the UWP fix?

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited February 2016

    Are effects broken completely right now? Or am I experiencing something weird? So I set an Effect on ONE Entry element I have and yet ALL Entry elements change color. So here is the effect:

    public class EntryTintEffect : PlatformEffect
        {
    
            private void SetColor( )
            {
    
                Entry element = Element as Entry;
                if( element == null )
                    return;
    
                this.Control.Background.SetTint(Color.Red.ToAndroid( ));// element.TextColor.ToAndroid( ));
    
                //this.Control.Background.SetTint(element.TextColor.ToAndroid( ));
    
            }
    
            protected override void OnAttached( )
            {
                SetColor( );
            }
    
            protected override void OnDetached( )
            {
    
            }
    
            protected override void OnElementPropertyChanged( System.ComponentModel.PropertyChangedEventArgs args )
            {
                base.OnElementPropertyChanged(args);
    
                if(args.PropertyName == "TextColor")
                {
                    SetColor( );
                }
            }
    }
    

    Every Entry element in my entire application now has a red underline when I put the effect on only one control.
    Ideas?

    EDIT: Had to change code slightly to be seen here on the forums(ughhhhh fix this!)

    Edit (from TheRealJasonSmith): Fixed your formatting :)

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @BradChase.2654 without having run that effect yet, can you just put a breakpoint in and see how often SetColor is being called?

  • BradChase.2654BradChase.2654 USMember ✭✭✭

    @TheRealJasonSmith I'll check in the AM. Thanks for the fix, it seems to not like compiler directives.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited February 2016

    @TheRealJasonSmith OK So ran a test and removed all the SetColor calls except for OnAttached. And it gets called once but is applied to all controls. Maybe I am not using Effects right? Are they a static/global effect or are they used per control?

    So to explain clearly, I set the effect on only one element, the OnAttached gets called once, and it is a global effect on all elements(I return if not of type Entry).

    EDIT: I should note that we are still on Xamarin 3 because WCF is broken in 4. I dont think the mono libraries should cause other issues with this specific one, but it might help if you guys cant repro it.

  • @BradChase.2654 From reading your code I think you are actually modifying the tint color of the background drawable of your control (instead of modifying the control itself). This background drawable might be shared with other text fields.
    Try creating a new background drawable with tint color and assign that to your control.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited February 2016

    @DominikWeber ahh good eye. I will look into it and see what that option does. Can you help me understand what that background might do? Is it a static, virtualized, or redrawn maybe somehow? I agree that it seems that is the case, I just don't know enough on why it is heh :).

    Edit: to add it is the standard Entry control.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited February 2016

    @DominikWeber @TheRealJasonSmith Ok so I ran some more tests and I cant find any other way to set the tint color besides these two ways:

    editText.Background.SetColorFilter(Color.Green.ToAndroid( ), PorterDuff.Mode.SrcIn);
    &
    editText.Background.SetTint(Color.Red.ToAndroid( ));

    Both of those change the entire applications tint on EditText controls. Now here is the weird part:

    Taking out those lines and changing them to the TextColor:

    editText.SetTextColor(Color.Blue.ToAndroid( ));

    What do you think would happen? Well your wrong, that actually only applies to the control that the effect was put on. Why the difference?

    EDIT: Just to add I still need the tint color changed but i just wanted to show that the text color behaves differently.

Sign In or Register to comment.