Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

No focus issue : Entry inside a listviewDatatemplate

$
0
0

Hello,

In my application, I have a listview with itemTemplate that is choosen by a templateselector.

This is my listView with the itemTemplate :

<ListView x:Name="ContentList" Grid.Row="2" Grid.Column="0"
                      Grid.ColumnSpan="11" Grid.RowSpan="3"
                      ItemsSource="{Binding Content}" HasUnevenRows="True">
              <ListView.ItemTemplate>
                <DataTemplate>
                  <ViewCell>
                    <Grid x:Name="Grid" BindingContext="{Binding}" BackgroundColor="White">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="60" />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>
                    <!--<Entry Grid.Row="0" Grid.Column="2" BindingContext="{Binding}" Text="{Binding Value}"
                                                                WidthRequest="250"
                                                                IsEnabled="True"
                                                                VerticalOptions="Center"
                                                                Placeholder="{Binding Name}" />-->
                    <controls:ExtendedEntry Grid.Row="0" Grid.Column="2" BindingContext="{Binding}" Text="{Binding Value}"
                                            WidthRequest="250"
                                            IsEnabled="True" IsPassword="{Binding IsPassword}"
                                            VerticalOptions="Center"
                                            Placeholder="{Binding Name}" />
                      </Grid>
                  </ViewCell>
                </DataTemplate>
              </ListView.ItemTemplate>
            </ListView>

This is a small viewModel to test with :

public class Block
{
    public Block(string name, object value, bool isPassword)
    {
    Name = name;
    Value = value;
    IsPassword = isPassword;
    }

    public object Value {get;set;}
    public string Name {get;set;}
    public IsPassword {get;set;}
}

public class MainVM
{
    public ObservableCollection<Block> Content {get;set;}
    public MainVM()
    {
    Content = new ObservableCollection<Block>();
    var block1 = new Block("User", "MyUsername", false);
    Content.Add(block1);
    var block2 = new Block("Password", "MySecretPassword", true);
    Content.Add(block2);
}

My customControl is here : http://pastebin.com/Kq7kMJTE

My renderer : http://pastebin.com/jqxR4XXu
Remove the regex match, because it's a custom property of the control that I removed, it's not mandatory

I can't get the focus to my entry, I manage to force the keyboard to appear, but my text is never update if I press a key.

Thanks for your help


Viewing all articles
Browse latest Browse all 77050

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>