In my MainPage I am using a Custom Control which is an Entry and 2 buttons. I need to use the ".isFocused" property for the Entry in the ViewModel to do something, how can I do it?
I must get x:Name of the entry? I dont know can I do this, but I need to use .isFocused for the entry,so that when I click on the entry, a menu that I have is closed.
My Code:
CustomContol.xaml:
<?xml version="1.0" encoding="UTF-8" ?>
<ContentView
x:Class="Aname.Xamarin.UIControls.Controls.CKEditor"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="CKEditorView">
<ContentView.Content>
<StackLayout>
<Frame
Margin="0,0,0,2"
Padding="0,0,0,0"
BackgroundColor="White"
BorderColor="{Binding BorderColor}"
CornerRadius="{Binding CornerRadius}"
HasShadow="False">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ImageButton
Grid.Column="0"
Margin="10,0,0,0"
BackgroundColor="Transparent"
Command="{Binding Source={x:Reference CKEditorView}, Path=BindingContext.EmojiCommand}"
HorizontalOptions="Start"
Source="{Binding LeftSideIcon}"
WidthRequest="30" />
<Entry
x:Name="EntryControl"
Grid.Column="1"
Margin="0,0,50,0"
HorizontalOptions="Fill"
Keyboard="Chat"
Placeholder="{Binding Placeholder}"
Text="{Binding EntryText}"
TextColor="Black" />
<ImageButton
Grid.Column="1"
Margin="0,0,10,0"
BackgroundColor="Transparent"
Command="{Binding Source={x:Reference CKEditorView}, Path=BindingContext.SendCommand}"
HorizontalOptions="End"
Source="{Binding Source={x:Reference CKEditorView}, Path=RightSideIcon}"
WidthRequest="35" />
</Grid>
</Frame>
<Frame Margin="0,-8,0,0" IsVisible="{Binding Source={x:Reference CKEditorView}, Path=BoxVisible}">
<CollectionView
Margin="-10,-15,-10,-10"
HeightRequest="250"
ItemsSource="{Binding Source={x:Reference CKEditorView}, Path=EmojiItemSource}"
VerticalScrollBarVisibility="Never">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal" Span="5" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<ImageButton
Padding="5"
BackgroundColor="Transparent"
Command="{Binding Source={x:Reference CKEditorView}, Path=BindingContext.MethodCommandEmoji}"
CommandParameter="{Binding EmojiMethodCommand}"
HeightRequest="44"
Source="{Binding EmojiSource}"
WidthRequest="44" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Frame>
</StackLayout>
</ContentView.Content>
</ContentView>
MainPage.xaml:
<StackLayout AbsoluteLayout.LayoutBounds="0,1,AutoSize,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional">
<fav:CKEditor
x:Name="entrycontrol"
BorderColor="{Binding BorderColor}"
BoxVisible="{Binding IsVisible}"
CornerRadius="{Binding CornerRadius}"
EmojiItemSource="{Binding EmojiList}"
LeftSideIcon="{Binding LeftSideIcon}"
Placeholder="{Binding Placeholder}"
RightSideIcon="{Binding RightSideIcon}"
Text="{Binding EntryText}" />
</StackLayout>