Share via

Access DataTemplate's controls without binding

Anonymous
2021-12-06T21:29:22.483+00:00

Hi,

I have below label (MyLabel) and I want to ask how can I access the label without ViewModel Binding to read and set its properties?

<SyncfusionListView:SfListView x:Name="ListViewBrowseNotification">
    <SyncfusionListView:SfListView.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Label x:Name="MyLabel" Grid.Row="0" />
        </DataTemplate>
    </SyncfusionListView:SfListView.ItemTemplate>
</SyncfusionListView:SfListView>

Thanks,
Jassim

Developer technologies | .NET | Xamarin
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,866 Reputation points
    2021-12-07T01:14:39.877+00:00

    You really cant. You can bind to most properties of a control. For example can use an IValueConverter to change the color of a font based on account balance

    https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Data.IValueConverter?view=winrt-22000

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.