Expandable list don't expand children after Search executed












0















With the help of this 2 Tutorial : https://www.youtube.com/watch?v=mTf6zHsM1y8 and https://www.youtube.com/watch?v=GG10QPrRC3w an Expandable works normal, Add Searchbar search works normal but after search has been executed Expandable list do not expand wondering where I did wrong Please help Thanks.



LexisPage.xaml(Content)



<ContentPage.BindingContext>
<local:LexisListModel/>
</ContentPage.BindingContext>



LexisPage.xaml



<Grid BackgroundColor="Black">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="8*" />
</Grid.RowDefinitions>

<SearchBar Grid.Row="0"
x:Name="MySearch"
Text="{Binding Word}"
Margin="2,2,2,0"
BackgroundColor="White"
CancelButtonColor="Black"
Placeholder="Search"
TextChanged="MySearch_TextChanged"
PlaceholderColor="LightGray"/>

<ListView Margin="2,0,2,2"
Grid.Row="1"
x:Name="MyList"
BackgroundColor="White"
ItemTapped="ListViewItem_Tabbed"
ItemsSource="{Binding Words}"
HasUnevenRows="True" >

<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="5">

<Label Text="{Binding Chang}"
FontSize="Medium"
TextColor="Black"/>

<StackLayout IsVisible="{Binding Isvisible}"
BackgroundColor="DarkGray"
Margin="2,2,2,2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Label Text="{Binding Hint}"
WidthRequest="110"
Margin="2,2,2,2"
FontSize="5"
Font="Italic"
TextColor="Blue"/>

<Label Text="{Binding English}"
HorizontalOptions="Center"
WidthRequest="110"
FontSize="15"
TextColor="White"/>
</Grid>

<Label Text="{Binding Defination}"
WidthRequest="100"
Margin="2"
FontSize="15"
TextColor="White"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>


LexisPage.xaml.cs



public ObservableCollection<Word> Words { get; set; }

public LexisPage()
{
InitializeComponent();
ViewList = new LexisListModel();
BindingContext = ViewList;
}

private void ListViewItem_Tabbed(object sender, ItemTappedEventArgs e)
{
Word word = e.Item as Word;
LexisListModel vm = BindingContext as LexisListModel;
vm?.ShowOrHiddenWords(word);
}

public LexisListModel ViewList { get; set; }

private void MySearch_TextChanged(object sender, TextChangedEventArgs e)
{

MyList.BeginRefresh();
MyList.ItemsSource = string.IsNullOrWhiteSpace(e.NewTextValue)
? ViewList.Words
: ViewList.Words
.Where(i => i.Chang.ToLower()
.Contains(e.NewTextValue));

LexisListModel vm = BindingContext as LexisListModel;

MyList.EndRefresh();
}


ListViewModel.cs



    private Word _oldWord;
public ObservableCollection<Word> Words { get; set; }
public LexisListModel()
{
Words = new ObservableCollection<Word>
{
new Word{Chang="Aest", Hint="Eng", English="Teste", Defination="Test 1 2 3[TEST]" },
new Word{Chang="Best", Hint="Eng", English="Testet", Defination="Test 1 2 3 4[TEST]" },
new Word{Chang="Cest", Hint="Eng", English="Testete", Defination="Test 1 2 3 4 5[TEST]" },
new Word{Chang="Dest", Hint="Eng", English="Testetet", Defination="Test 1 2 3 4 5 6[TEST]" },
};
}

public void ShowOrHiddenWords(Word word)
{
if(_oldWord == word)
{
word.Isvisible = !word.Isvisible;
UpDateWords(word);
}
else
{
if(_oldWord != null)
{
_oldWord.Isvisible = false;
UpDateWords(_oldWord);
}
word.Isvisible = true;
UpDateWords(word);
}
_oldWord = word;
}

private void UpDateWords(Word word)
{
int Index = Words.IndexOf(word);
Words.Remove(word);
Words.Insert(Index, word);
}
}


Word.cs



public class Word
{
public string Chang { get; set; }
public string Hint { get; set; }
public string English { get; set; }
public string Defination { get; set; }
public bool Isvisible { get; internal set; }
}


App.xaml.cs



public App()
{
InitializeComponent();

MainPage = new LexisPage();
}









share|improve this question

























  • Would you share your full code here? That would make it easier to figure out the issue.

    – AbbyWang
    Nov 21 '18 at 6:35











  • Update Words.cs and App.xaml.cs this is my complete code, Thanks

    – Naz Mko
    Dec 2 '18 at 11:07
















0















With the help of this 2 Tutorial : https://www.youtube.com/watch?v=mTf6zHsM1y8 and https://www.youtube.com/watch?v=GG10QPrRC3w an Expandable works normal, Add Searchbar search works normal but after search has been executed Expandable list do not expand wondering where I did wrong Please help Thanks.



LexisPage.xaml(Content)



<ContentPage.BindingContext>
<local:LexisListModel/>
</ContentPage.BindingContext>



LexisPage.xaml



<Grid BackgroundColor="Black">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="8*" />
</Grid.RowDefinitions>

<SearchBar Grid.Row="0"
x:Name="MySearch"
Text="{Binding Word}"
Margin="2,2,2,0"
BackgroundColor="White"
CancelButtonColor="Black"
Placeholder="Search"
TextChanged="MySearch_TextChanged"
PlaceholderColor="LightGray"/>

<ListView Margin="2,0,2,2"
Grid.Row="1"
x:Name="MyList"
BackgroundColor="White"
ItemTapped="ListViewItem_Tabbed"
ItemsSource="{Binding Words}"
HasUnevenRows="True" >

<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="5">

<Label Text="{Binding Chang}"
FontSize="Medium"
TextColor="Black"/>

<StackLayout IsVisible="{Binding Isvisible}"
BackgroundColor="DarkGray"
Margin="2,2,2,2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Label Text="{Binding Hint}"
WidthRequest="110"
Margin="2,2,2,2"
FontSize="5"
Font="Italic"
TextColor="Blue"/>

<Label Text="{Binding English}"
HorizontalOptions="Center"
WidthRequest="110"
FontSize="15"
TextColor="White"/>
</Grid>

<Label Text="{Binding Defination}"
WidthRequest="100"
Margin="2"
FontSize="15"
TextColor="White"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>


LexisPage.xaml.cs



public ObservableCollection<Word> Words { get; set; }

public LexisPage()
{
InitializeComponent();
ViewList = new LexisListModel();
BindingContext = ViewList;
}

private void ListViewItem_Tabbed(object sender, ItemTappedEventArgs e)
{
Word word = e.Item as Word;
LexisListModel vm = BindingContext as LexisListModel;
vm?.ShowOrHiddenWords(word);
}

public LexisListModel ViewList { get; set; }

private void MySearch_TextChanged(object sender, TextChangedEventArgs e)
{

MyList.BeginRefresh();
MyList.ItemsSource = string.IsNullOrWhiteSpace(e.NewTextValue)
? ViewList.Words
: ViewList.Words
.Where(i => i.Chang.ToLower()
.Contains(e.NewTextValue));

LexisListModel vm = BindingContext as LexisListModel;

MyList.EndRefresh();
}


ListViewModel.cs



    private Word _oldWord;
public ObservableCollection<Word> Words { get; set; }
public LexisListModel()
{
Words = new ObservableCollection<Word>
{
new Word{Chang="Aest", Hint="Eng", English="Teste", Defination="Test 1 2 3[TEST]" },
new Word{Chang="Best", Hint="Eng", English="Testet", Defination="Test 1 2 3 4[TEST]" },
new Word{Chang="Cest", Hint="Eng", English="Testete", Defination="Test 1 2 3 4 5[TEST]" },
new Word{Chang="Dest", Hint="Eng", English="Testetet", Defination="Test 1 2 3 4 5 6[TEST]" },
};
}

public void ShowOrHiddenWords(Word word)
{
if(_oldWord == word)
{
word.Isvisible = !word.Isvisible;
UpDateWords(word);
}
else
{
if(_oldWord != null)
{
_oldWord.Isvisible = false;
UpDateWords(_oldWord);
}
word.Isvisible = true;
UpDateWords(word);
}
_oldWord = word;
}

private void UpDateWords(Word word)
{
int Index = Words.IndexOf(word);
Words.Remove(word);
Words.Insert(Index, word);
}
}


Word.cs



public class Word
{
public string Chang { get; set; }
public string Hint { get; set; }
public string English { get; set; }
public string Defination { get; set; }
public bool Isvisible { get; internal set; }
}


App.xaml.cs



public App()
{
InitializeComponent();

MainPage = new LexisPage();
}









share|improve this question

























  • Would you share your full code here? That would make it easier to figure out the issue.

    – AbbyWang
    Nov 21 '18 at 6:35











  • Update Words.cs and App.xaml.cs this is my complete code, Thanks

    – Naz Mko
    Dec 2 '18 at 11:07














0












0








0








With the help of this 2 Tutorial : https://www.youtube.com/watch?v=mTf6zHsM1y8 and https://www.youtube.com/watch?v=GG10QPrRC3w an Expandable works normal, Add Searchbar search works normal but after search has been executed Expandable list do not expand wondering where I did wrong Please help Thanks.



LexisPage.xaml(Content)



<ContentPage.BindingContext>
<local:LexisListModel/>
</ContentPage.BindingContext>



LexisPage.xaml



<Grid BackgroundColor="Black">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="8*" />
</Grid.RowDefinitions>

<SearchBar Grid.Row="0"
x:Name="MySearch"
Text="{Binding Word}"
Margin="2,2,2,0"
BackgroundColor="White"
CancelButtonColor="Black"
Placeholder="Search"
TextChanged="MySearch_TextChanged"
PlaceholderColor="LightGray"/>

<ListView Margin="2,0,2,2"
Grid.Row="1"
x:Name="MyList"
BackgroundColor="White"
ItemTapped="ListViewItem_Tabbed"
ItemsSource="{Binding Words}"
HasUnevenRows="True" >

<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="5">

<Label Text="{Binding Chang}"
FontSize="Medium"
TextColor="Black"/>

<StackLayout IsVisible="{Binding Isvisible}"
BackgroundColor="DarkGray"
Margin="2,2,2,2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Label Text="{Binding Hint}"
WidthRequest="110"
Margin="2,2,2,2"
FontSize="5"
Font="Italic"
TextColor="Blue"/>

<Label Text="{Binding English}"
HorizontalOptions="Center"
WidthRequest="110"
FontSize="15"
TextColor="White"/>
</Grid>

<Label Text="{Binding Defination}"
WidthRequest="100"
Margin="2"
FontSize="15"
TextColor="White"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>


LexisPage.xaml.cs



public ObservableCollection<Word> Words { get; set; }

public LexisPage()
{
InitializeComponent();
ViewList = new LexisListModel();
BindingContext = ViewList;
}

private void ListViewItem_Tabbed(object sender, ItemTappedEventArgs e)
{
Word word = e.Item as Word;
LexisListModel vm = BindingContext as LexisListModel;
vm?.ShowOrHiddenWords(word);
}

public LexisListModel ViewList { get; set; }

private void MySearch_TextChanged(object sender, TextChangedEventArgs e)
{

MyList.BeginRefresh();
MyList.ItemsSource = string.IsNullOrWhiteSpace(e.NewTextValue)
? ViewList.Words
: ViewList.Words
.Where(i => i.Chang.ToLower()
.Contains(e.NewTextValue));

LexisListModel vm = BindingContext as LexisListModel;

MyList.EndRefresh();
}


ListViewModel.cs



    private Word _oldWord;
public ObservableCollection<Word> Words { get; set; }
public LexisListModel()
{
Words = new ObservableCollection<Word>
{
new Word{Chang="Aest", Hint="Eng", English="Teste", Defination="Test 1 2 3[TEST]" },
new Word{Chang="Best", Hint="Eng", English="Testet", Defination="Test 1 2 3 4[TEST]" },
new Word{Chang="Cest", Hint="Eng", English="Testete", Defination="Test 1 2 3 4 5[TEST]" },
new Word{Chang="Dest", Hint="Eng", English="Testetet", Defination="Test 1 2 3 4 5 6[TEST]" },
};
}

public void ShowOrHiddenWords(Word word)
{
if(_oldWord == word)
{
word.Isvisible = !word.Isvisible;
UpDateWords(word);
}
else
{
if(_oldWord != null)
{
_oldWord.Isvisible = false;
UpDateWords(_oldWord);
}
word.Isvisible = true;
UpDateWords(word);
}
_oldWord = word;
}

private void UpDateWords(Word word)
{
int Index = Words.IndexOf(word);
Words.Remove(word);
Words.Insert(Index, word);
}
}


Word.cs



public class Word
{
public string Chang { get; set; }
public string Hint { get; set; }
public string English { get; set; }
public string Defination { get; set; }
public bool Isvisible { get; internal set; }
}


App.xaml.cs



public App()
{
InitializeComponent();

MainPage = new LexisPage();
}









share|improve this question
















With the help of this 2 Tutorial : https://www.youtube.com/watch?v=mTf6zHsM1y8 and https://www.youtube.com/watch?v=GG10QPrRC3w an Expandable works normal, Add Searchbar search works normal but after search has been executed Expandable list do not expand wondering where I did wrong Please help Thanks.



LexisPage.xaml(Content)



<ContentPage.BindingContext>
<local:LexisListModel/>
</ContentPage.BindingContext>



LexisPage.xaml



<Grid BackgroundColor="Black">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="8*" />
</Grid.RowDefinitions>

<SearchBar Grid.Row="0"
x:Name="MySearch"
Text="{Binding Word}"
Margin="2,2,2,0"
BackgroundColor="White"
CancelButtonColor="Black"
Placeholder="Search"
TextChanged="MySearch_TextChanged"
PlaceholderColor="LightGray"/>

<ListView Margin="2,0,2,2"
Grid.Row="1"
x:Name="MyList"
BackgroundColor="White"
ItemTapped="ListViewItem_Tabbed"
ItemsSource="{Binding Words}"
HasUnevenRows="True" >

<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="5">

<Label Text="{Binding Chang}"
FontSize="Medium"
TextColor="Black"/>

<StackLayout IsVisible="{Binding Isvisible}"
BackgroundColor="DarkGray"
Margin="2,2,2,2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Label Text="{Binding Hint}"
WidthRequest="110"
Margin="2,2,2,2"
FontSize="5"
Font="Italic"
TextColor="Blue"/>

<Label Text="{Binding English}"
HorizontalOptions="Center"
WidthRequest="110"
FontSize="15"
TextColor="White"/>
</Grid>

<Label Text="{Binding Defination}"
WidthRequest="100"
Margin="2"
FontSize="15"
TextColor="White"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>


LexisPage.xaml.cs



public ObservableCollection<Word> Words { get; set; }

public LexisPage()
{
InitializeComponent();
ViewList = new LexisListModel();
BindingContext = ViewList;
}

private void ListViewItem_Tabbed(object sender, ItemTappedEventArgs e)
{
Word word = e.Item as Word;
LexisListModel vm = BindingContext as LexisListModel;
vm?.ShowOrHiddenWords(word);
}

public LexisListModel ViewList { get; set; }

private void MySearch_TextChanged(object sender, TextChangedEventArgs e)
{

MyList.BeginRefresh();
MyList.ItemsSource = string.IsNullOrWhiteSpace(e.NewTextValue)
? ViewList.Words
: ViewList.Words
.Where(i => i.Chang.ToLower()
.Contains(e.NewTextValue));

LexisListModel vm = BindingContext as LexisListModel;

MyList.EndRefresh();
}


ListViewModel.cs



    private Word _oldWord;
public ObservableCollection<Word> Words { get; set; }
public LexisListModel()
{
Words = new ObservableCollection<Word>
{
new Word{Chang="Aest", Hint="Eng", English="Teste", Defination="Test 1 2 3[TEST]" },
new Word{Chang="Best", Hint="Eng", English="Testet", Defination="Test 1 2 3 4[TEST]" },
new Word{Chang="Cest", Hint="Eng", English="Testete", Defination="Test 1 2 3 4 5[TEST]" },
new Word{Chang="Dest", Hint="Eng", English="Testetet", Defination="Test 1 2 3 4 5 6[TEST]" },
};
}

public void ShowOrHiddenWords(Word word)
{
if(_oldWord == word)
{
word.Isvisible = !word.Isvisible;
UpDateWords(word);
}
else
{
if(_oldWord != null)
{
_oldWord.Isvisible = false;
UpDateWords(_oldWord);
}
word.Isvisible = true;
UpDateWords(word);
}
_oldWord = word;
}

private void UpDateWords(Word word)
{
int Index = Words.IndexOf(word);
Words.Remove(word);
Words.Insert(Index, word);
}
}


Word.cs



public class Word
{
public string Chang { get; set; }
public string Hint { get; set; }
public string English { get; set; }
public string Defination { get; set; }
public bool Isvisible { get; internal set; }
}


App.xaml.cs



public App()
{
InitializeComponent();

MainPage = new LexisPage();
}






android forms xamarin searchbar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 '18 at 9:54







Naz Mko

















asked Nov 14 '18 at 0:37









Naz MkoNaz Mko

13




13













  • Would you share your full code here? That would make it easier to figure out the issue.

    – AbbyWang
    Nov 21 '18 at 6:35











  • Update Words.cs and App.xaml.cs this is my complete code, Thanks

    – Naz Mko
    Dec 2 '18 at 11:07



















  • Would you share your full code here? That would make it easier to figure out the issue.

    – AbbyWang
    Nov 21 '18 at 6:35











  • Update Words.cs and App.xaml.cs this is my complete code, Thanks

    – Naz Mko
    Dec 2 '18 at 11:07

















Would you share your full code here? That would make it easier to figure out the issue.

– AbbyWang
Nov 21 '18 at 6:35





Would you share your full code here? That would make it easier to figure out the issue.

– AbbyWang
Nov 21 '18 at 6:35













Update Words.cs and App.xaml.cs this is my complete code, Thanks

– Naz Mko
Dec 2 '18 at 11:07





Update Words.cs and App.xaml.cs this is my complete code, Thanks

– Naz Mko
Dec 2 '18 at 11:07












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291516%2fexpandable-list-dont-expand-children-after-search-executed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291516%2fexpandable-list-dont-expand-children-after-search-executed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud