Search code examples
c#silverlightwindows-phone

How to show a userControl at the bottom of a page in wp silverlight 8.1


I have a user control. I want to show it at the bottom of all page in my app. I set the verticalOffset like this.

if (App.Current.Host.Content.ScaleFactor==150)
    popUp.VerticalOffset = App.Current.Host.Content.ActualHeight - 230;// 160;
else
    popUp.VerticalOffset = App.Current.Host.Content.ActualHeight - 160;

Where 160 is my userControl height.

I don't know the exact way. Anyway it's works for some device which have softkey. Some device that satisfies if condition and has no softKey create a gap at the bottom of 70/72 pixels of the page.

Is it possible to check the softkey availability for silverlight or show the user control at the bottom exactly?


Solution

  • Only I need to add sizeChanged Events on page constructor then set the verticaloffset of the popUp like this.

    Popup popUP = new Popup();
    public MainPage()
    {
       InitializeComponent();
       this.SizeChanged += MainPage_SizeChanged;
     }
    
    double systemTrayHeight =30;
    double popUPHeight = 200;
    private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        if (popUP.IsOpen)
             popUP.IsOpen = false;
         popUP.Child = new PopUP();
         popUP.VerticalOffset = e.NewSize.Height + systemTrayHeight - popUPHeight;
         popUP.IsOpen = true;
    }
    

    sample project