ListBox is Not Automatically Expanding with Dynamic Data Adding through
'PhoneTextBox' wp7
I would like to perform something's like fb comment Layout.
and I am Using Following Code To perform this task :
// Constructor
string []content;
public MainPage()
{
InitializeComponent();
content = new string[11] { "Great stories produce the ideas which
help children to know how the cleverness and wise decisions take
the people out of the dangerous and most tricky situations.",
"No virtue is as noble as kindness. The
stories "Prince Frog", "Dove and the
ant" and others teaches them the
importance of being kind to even to the
small god made creatures of this
earth.",
"Honesty is a key to success and honest
people are duly rewarded. These stories
show honesty is a most beautiful
quality to be possessed, liked and
appreciated.",
"Humbleness makes us kind hearted and
soft spoken- the virtues which will
always be deemed and valued in the eyes
of the others.",
"Realize the importance of hard work
through these evergreen stories. These
popular stories are the inroads to the
very roots of the concept "Hard work is
a road to success.",
"If you speak the truth, your children
will speak too. This would help them
built the trust and reputation in their
society and around them.",
"Courageous child can easily cross each
milestones of life with ease, then why
not we too help our children to be
strong for the others too to follow.",
"True Friendship is a God's precious
gift and a commitment for togetherness,
and sharing and caring.",
"Understand the value of being united,
to overcome any difficult situation and
understand the meaning of working in a
team and grow as a virtuous and a
strong human being.",
"Obeying the elders will ultimately be
good for you. Stories like \"Three
goats and the Wolf\" can help your
children understand the value of being
obedient.",
"Greediness leads to destruction. It
causes obsession which is more harmful.
Let us know how through these great
stories." };
populate_list();
}
private void populate_list()
{
for (int i = 0; i < content.Length; i++)
{
//mainlist.Items.Add(content[i]);
var maintext = new TextBlock();
maintext.Text = content[i];
maintext.TextWrapping = TextWrapping.Wrap;
StackPanel stkpanel = new StackPanel();
stkpanel.Width = 480;
stkpanel.Height = 124;
stkpanel.Children.Add(maintext);
var expander = new ExpanderView();
var phonetextbox = new PhoneTextBox();
phonetextbox.Hint = "Add a Comment";
phonetextbox.ActionIcon = new
System.Windows.Media.Imaging.BitmapImage(new
Uri("/search.png", UriKind.RelativeOrAbsolute));
StackPanel stkpanel_new = new StackPanel();
stkpanel_new.Width = 480;
phonetextbox.ActionIconTapped += (s, e) =>
{
if (!string.IsNullOrEmpty(phonetextbox.Text))
{
expander.Items.Add(phonetextbox.Text);
expander.IsExpanded = true;
//stkpanel_new.Height = stkpanel_new.Height + 20;
}
};
stkpanel_new.Children.Add(phonetextbox);
stkpanel_new.Children.Add(expander);
mainlist.Items.Add(stkpanel);
mainlist.Items.Add(stkpanel_new);
}
}
But i Got problem on Dynamic Comment insertion when user entered text in
phonetextbox and press on its Icon the comment just added behind the
listbox 2nd element (means ExpanderView will be expanded but listbox
further elements are not adjusting it dynamically ).
Am i Doing Something wrong or it is a Framework limitation ?? Help .
Regards
Pardeep Sharma
No comments:
Post a Comment