Bug 59950 - FindByName<T> Returns copy of object in UWP
Summary: FindByName<T> Returns copy of object in UWP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-10-04 10:53 UTC by ksemenenko
Modified: 2017-12-07 14:03 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 59950 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description ksemenenko 2017-10-04 10:53:04 UTC
In UWP I found a bug, the function FindByName<T> gets a copy of the object.
The change in the object does not appear in the View.

ViewCell vc = (ViewCell)sender;
var control = vc.View.FindByName<Label>("MyLabel");
control.Text = "new test";



I see in the debugger that the values have changed, but visually, nothing changes, no text, no focus, no other action.
Comment 1 Paul DiPietro [MSFT] 2017-10-11 21:26:35 UTC
FindByName<T> seems to work on UWP/2.4 with a basic Label. Does it occur only in UWP with ViewCells? Can you upload a reproduction?
Comment 2 ksemenenko 2017-10-12 08:55:29 UTC
Yes, it's in ViewCell.
it happened in the event Tapped. when I changed the style of the selected item.

xaml code

<ListView Grid.Row="0" SelectedItem="{Binding SelectedProperty}" HasUnevenRows="True" ItemsSource="{Binding Properties}"  SeparatorColor="Transparent">
			<ViewCell Tapped="Cell_OnTapped" >
				<Grid Margin="8" RowSpacing="0" ColumnSpacing="0" x:Name="Item" >

						<RowDefinition Height="*" />
						<RowDefinition Height="Auto"/>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="*"/>

					<BoxView  Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" HeightRequest="55"/>
					<Label Text="Some Text" Grid.Row="0" Grid.Column="0" VerticalOptions="Center" HorizontalOptions="Start" FontSize="{StaticResource TextSizeLabel}" x:Name="MyLabel" 
						   IsVisible="{Binding IsRequiredProperty}" TextColor="{StaticResource Negative}" FontFamily="{StaticResource SourceSansProSemibold}"/>

					<customControls:FieldViewControl BindingContext="{Binding}" x:Name="FieldView" FontSize="{StaticResource TextSizeField}" TextColor="Black" FontFamily="{StaticResource SourceSansProRegular}"
													 Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2" Unfocused="VisualElement_OnUnfocused" VerticalOptions="FillAndExpand" HorizontalOptions="Fill" />

Comment 3 Stephane Delcroix 2017-12-07 14:03:01 UTC
FindByName<T> is in the Xamarin.Forms.Internals namespace. Use it if it works for you, but do not complain if it does not :)