-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] [UWP] Template Disappears when Command Parameter Binding Set #8918
Comments
This also happens with ViewCells and ViewCell.ContextActions:
Tested this snippet in the sample provided. |
@Gh0stC0de thanks for verifying. know of any work around i might be able to do in the meantime? |
@djrpascu I think you could use a command with an object as command parameter and cast it. Something like:
|
@Gh0stC0de thanks for the suggestion, but it doesn't work. doesn't call the command. |
@djrpascu I forgot that you have to specify the I did the following changes to get it working:
MainPageViewModel:
|
@Gh0stC0de thanks sooo much! tested and works on iOS as well! never thought to set bindingcontext to the parent control and retrieve object that way! i was trying to get value through a converter but couldn't figure it out.. thanks again! |
@djrpascu This seems like it's a bug with DelegateCommand If I just change your DelegateCommands to Xamarin.Forms.Command then everything works perfectly with your sample. It all renderers, I click the command, and the parameter is passed and executed Using your sample if you enable CLR exceptions you'll get the following exception
It seems like for some reason the DelegateCommand is trying to pass in 'XFGithub.ViewModels.MainPageViewModel' as a parameter to the DelegateCommand |
@PureWeen this wouldn't be a bug with DelegateCommand. If you have a DelegateCommand and the CommandParameter passed in is not null and not a type of T by design it should throw an InvalidCastException. This seems to me that it would be a bug in Xamarin.Forms particularly if this is working on iOS and not UWP. The must be something in UWP that is causing the wrong value to be passed in for the Command Parameter. I should add as well that from what I see adding the binding source for the binding of the Command seems like it must be changing the BindingContext of the cell... even if I tried naming the cell and changing the binding of the CommandParameter it produced the same error. <ViewCell x:Name="cell">
<Button Command="{Binding BindingContext.MyCommand, Source={x:Reference page}}"
CommandParameter="{Binding BindingContext, Source={x:Reference cell}}" />
</ViewCell> |
I am having the same issue on Xamarin.Forms 5.0.0.2578 and UWP. Using Xamarin.Forms.Command instead of DelegateCommand is not an option since it does not have the method ObservesProperty which I use heavily in my viewmodels. Has anyone an idea, how to solve the issue? |
Description
I have a Listview with simple DataTemplate selector which presents one of either two templates. Once the CommandParameter Binding is defined to the current object ({Binding} or {Binding .}), the entire view for that template goes blank on UWP. Therefore, I'm not allowed to call the command with the current object. This works as expected when deploying out to iOS.
Steps to Reproduce
Sample project here https://github.com/djrpascu/XFGithub
Expected Behavior
Listview template displays contents properly and I'm able to pass the object into my command via CommandParameter.
Actual Behavior
Listview template goes blank.
Basic Information
Version with issue: 4.4.0.991265
Last known good version: N/A
IDE: VS Enterprise 2019 16.4.1
Platform Target Frameworks:
Android Support Library Version: N/A
Nuget Packages:
XF 4.4.0.991265
Prims.Unity.Forms 7.2.0.1422
NETStandard.Library 2.0.3
Affected Devices:
Windows 10 Desktop
Screenshots
Reproduction Link
https://github.com/djrpascu/XFGithub
The text was updated successfully, but these errors were encountered: