Issue
I have Label
in view, I need that Label
's view in my ViewModel
. I am using Dependency Service to set focus on Controls for Accessibility service, DS requires view
as a param.
This is my Label
<Label
AutomationProperties.IsInAccessibleTree="{Binding ShowNoResults}"
IsVisible="{Binding ShowNoResults}"
Text="{Binding ResultsHeader}"/>
I tried Command
but Label doesn't support command. Below code also not working
var view = GetView() as HomeworkView;
I am getting view
always null
. How can I fix this?
Solution
I am not quite sure what are you trying to achieve, but you can't access the View elements from you view model.
If you want to do something with the control, you can use the messaging center to do it, here is an example
in your ViewModel
MessagingCenter.Send(this, "your message here");
then in your page, you need to subscribe to this message from that view model and do the desired action
MessagingCenter.Instance.Unsubscribe<ViewModelClassNamedel>(this, "your message here");
MessagingCenter.Instance.Subscribe<ViewModelClassName>(this, "your message here", (data) =>
{
this.youControlName.Focus();
});
Answered By - Mohammad Shaban
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.