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

Tags:
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:
Status:
NEEDINFO

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";

or 

control?.Focus();


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">
	<ListView.ItemTemplate>
		<DataTemplate>
			<ViewCell Tapped="Cell_OnTapped" >
				<Grid Margin="8" RowSpacing="0" ColumnSpacing="0" x:Name="Item" >

					<Grid.RowDefinitions>
						<RowDefinition Height="*" />
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="*"/>
					</Grid.ColumnDefinitions>

					<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" />

				</Grid>
			</ViewCell>
		</DataTemplate>
	</ListView.ItemTemplate>
</ListView>
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 :)