list picker in popup windows phone - windows-phone-7

I am using a list picker in popup. But when I click on list picker, its full mode opens behind popup. How can I make my list picker full mode window to appear above popup.
MY list picker is in the user control called WindowsPhoneControl1
Popup Mypopup = new Popup();
Mypopup.Height = 300;
Mypopup.Width = 400;
Mypopup.VerticalOffset = 100;
WindowsPhoneControl1 Mycontrol = new WindowsPhoneControl1();
Mypopup.Child = Mycontrol;
Mypopup.IsOpen = true;
i didn't find a solution
thank you

Try defining the Popup in XAML.
such as so:
<Popup IsOpen="true" Name="MyPopup" Height="300" Width="400" VerticleOffset="100"/>
Make sure IsOpen is true, then try to right-click on the ListPicker and choose it's order: bring-to-front.
I know it's simple, but I didn't see you mention trying it, so give it a shot!

Related

How to position a view right above the keyboard?

I'm writing a Forms app. How to position a view right at the bottom of the screen and when some entry is focused and the keyboard is visible, the view to be right above the keyboard? On android, it is possible to set Window.SetSoftInputMode(SoftInput.AdjustResize) and that will make the Content resize every time the keyboard is appearing/disappearing. However, I need the status bar to be transparent and SoftInput.AdjustResize doesn't work with WindowManagerFlags.TranslucentStatus. My question is, how do I position a view right above the keyboard without setting SoftInput.AdjustResize?
Take this example:
public Page1()
{
InitializeComponent();
var al = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var button = new BoxView {Color = Color.Red, VerticalOptions = LayoutOptions.EndAndExpand};
var entry = new Entry {HorizontalOptions = LayoutOptions.Fill};
al.Children.Add(entry);
al.Children.Add(button);
Content = al;
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
}
If you run this code, when you'll press the input, nothing will change, the "button" will remain on the bottom of the screen not visible because of the overlaying keyboard.
If we add Window.SetSoftInputMode(SoftInput.AdjustResize) in MainActivity's onCreate it works fine, the box is moved above the keyboard on entry's focus.
Also, if we change Content = al; to Content = new ScrollView {Content = al};, it works fine.
However, if we add Window.AddFlags(WindowManagerFlags.TranslucentStatus); in MainActivity's onCreate, none of those methods work anymore.
Thanks in advance.
I'm writing a Forms app. How to position a view right at the bottom of
the screen and when some entry is focused and the keyboard is visible,
the view to be right above the keyboard?
If you are using Xamarin Forms, then wrapping your UI elements in a ScrollView should do the trick. Something like this if you are using XAML:
<ScrollView>
<ScrollView.Content>
// Your Original XAML content here
</ScrollView.Content>
<ScrollView
EDIT:
Looking at the example you just added, I THINK I know what is happening. So, the ScrollView Trick only works for elements that require keyboard input. I.e if you instead had an entry element at the bottom of the screen, and wrapped everything in a ScrollView like I suggested, then the keyboard should push the entry element up for you. However in your case you have a boxview at the bottom of the screen, which the keyboard simply runs over.
What you have for Content.SizedChanged is a good idea, however I don't think the size of the view actually changes when the keyboard pops up (at least, Content.SizeChanged isn't called when the keyboard pops up), so that part of your code is really only called on loading of the page from the MCVE you provided.
HOWEVER, I was able to move the 'button' up when the keyboard appears by doing this:
Replace
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
With
entry.Focused += (sender, e) =>
{
button.TranslationY -= 120;
};
You may have a heck of a time getting that magic translation number for all the different devices and orientations though. When I tested it on the iPhone 6 simulator I had to push way above 120 before I could see it above the keyboard.
Hope that helps!

fire a popup when ApplicationBarMenuItem clicked

I need to fire a popup when ApplicationBarMenuItem clicked. but nothing happen when I click MenuItem. here is my code;
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Go by date" Click="GoByDate_Click" />
</shell:ApplicationBar.MenuItems>
private void GoByDate_Click(object sender, EventArgs e)
{
Popup popup = new Popup();
popup.Height = 480;
popup.Width = 480;
popup.VerticalOffset = 100;
DatePopupControl datePopup = new DatePopupControl(); // just a user control comes when add new
popup.Child = datePopup;
popup.IsOpen = true;
}
Something is wrong with your DatePopupControl, because your code worked fine for my own test control. Can you provide DatePopupControl source code?
Alright, let me try to guess. My first theory is: there is nothing to show in this popup.
For example, if you add a userControl, which has only Grid tag inside without anything, you will see in the editor in Visual Studio, but it won't be visible as a popup child. But if you add a single textblock, it will be.

WP7 how to know when popup shows up?

I'm using popup to show my user control. I want to detect when the popup is REALLY shown up on the screen, then I show the progress bar, do some work, then hide the progress bar
MyDialog dialog = new MyDialog();
myPopup.Child = dialog;
myPopup.IsOpen = true;
dialog.progressLoading.Visibility = Visibility.Visible;
Thread.Sleep(3000)
dialog.progressLoading.Visibility = Visibility.Collapsed;
However, I realize that IsOpen = true doesnot show the popup instantly. The fact is that I must wait 3 seconds for it to show up.
How to know when popup shows up ?

how to add/show a UserControl (e.g. popup) in a WP7 app page?

hi i have created a user control.
now i want to add this control to a page e.g. when the user clicks a button (important is, that i dont want to add it direcly in xaml, i want to add id in the c# code section)
how to so this?
In your button's Click event, you could do something like:
MyControl control = new MyControl();
// Set whatever properties you need in your control here
LayoutRoot.Children.Add(control);
if (listBox1.Items.Count == 0)
{
Popup popup = new Popup();
WPCpopup po = new WPCpopup(popup);
popup.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = po;
popup.VerticalOffset = 300;
popup.IsOpen = true;
}
WPCpopup is usercontrol

Add Elements dynamically to The XAML page in Windows Phone 7

I'm new to WP7 and I want to know if there is any way to add items like a TextBlock to
a page dynamically using the .cs part??
Try this
var textBlock = new TextBlock();
// set some properties
YourMainContainer.Children.Add(textBlock); //
If you need more details just comment this
If you know the controls that you'd like to appear on the page dynamically, then I'd approach the problem by including those controls in the XAML and using the Visibility property on the controls to show and hide them. In Silverlight, the Visibility enumeration is limited to the values Visible and Collapsed, so when it isn't visible the it doesn't take up any space. You can control Visibility with data-binding by using a converter (search on "visibility bind converter") if you are intersted in pursuing that avenue. You can show/hide groups of controls by changing the Visibility of their parent control, such as StackPanel or custom control.
Try this one,
TextBlock txtmsg = new TextBlock();
txtmsg.Text = "New Program.";
txtmsg.Margin = new Thickness(10, 20, 10, 10);
txtmsg.TextWrapping = TextWrapping.Wrap;
txtmsg.FontSize = 28;
txtmsg.TextAlignment = TextAlignment.Center;
ContentPanel.Children.Add(txtmsg);

Resources