Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6866953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:14:54+00:00 2026-05-27T03:14:54+00:00

I’m trying to simulate an Android UI element that unfortunately doesn’t exist in Windows

  • 0

I’m trying to simulate an Android UI element that unfortunately doesn’t exist in Windows 7 phone: ListPreference

I thought about using a Popup, that would take exactly the whole screen (to simulate a modal window).

So the popup would be made of the following elements:

Popup -> Canvas -> Border -> StackPanel -> RadioButtons

The Canvas would be fully transparent (or lightly whitish to clearly show that the element underneath aren’t available)

The border would be made so it only big enough to contain all the RadioButtons
Then the StackPanel would be opaque and black.

Unfortunately, if I make the bottom canvas transparent, all children elements are also transparent. I can only make the elements more transparent.

The way transparency works is slightly different than with Android or iPhone (where it’s quite easy to have a parent fully transparent, but opaque children).

Is there a way to make a parent fully transparent with the children opaque?

Or maybe someone could suggest another way to simulate a modal window.
Who knows, maybe someone even developed a ListPreference-like UIElement 🙂

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:14:55+00:00Added an answer on May 27, 2026 at 3:14 am

    Here is how I ended up doing it.

    It works in a similar fashion as ListPreference on Android. The constructor takes a string, an array of string and an int indicating which is the default value

    When the windows is closed, the delegate Dismissed is called..

    So you call it like so:

    string[] choices = { "Choice 1", "Choice 2", "Choice3" };
    ListPreference lp = new ListPreference("name", choices, 1);
    lp.dismissed += new ListPreferences.DismissedHandler(lp_Dismissed);
    

    the code:

    public class ListPreference
    {
        Popup p;
        string Name;
        int oldValue;
    
        public delegate void DismissedHandler(string name, bool changed, int newvalue);
    
        public event DismissedHandler Dismissed;
    
        public bool IsOpen
        {
            get
            {
                return p.IsOpen;
            }
    
            set
            {
                p.IsOpen = value;
            }
        }
    
        public ListPreference(string name, Array elements, int default_value)
        {
            p = new Popup();
            Name = name;
            Dismissed = null;
            oldValue = default_value;
    
            double height = (App.Current.RootVisual as FrameworkElement).ActualHeight;
            double width = (App.Current.RootVisual as FrameworkElement).ActualWidth;
    
            p.VerticalOffset = SystemTray.IsVisible ? 32.0 : 0.0;
            p.Height = height;
            p.Width = width;
            Canvas canvas = new Canvas();
            SolidColorBrush colorBrush = new SolidColorBrush(Colors.Black);
            colorBrush.Opacity = 0.75;
            //Color.FromArgb(0xff, 0x8a, 0x8a, 0x8a));
            canvas.Background = colorBrush;
            //canvas.Opacity = 0.765;
            canvas.Height = height;
            canvas.Width = width;
            p.Child = canvas;
    
            Border border = new Border();
            border.Width = width - 50.0 * 2.0;
            border.BorderBrush = new SolidColorBrush(Colors.LightGray);
            border.BorderThickness = new Thickness(5.0);
            border.Background = new SolidColorBrush(Colors.Black);
            canvas.Children.Add(border);
    
            StackPanel panel2 = new StackPanel();
            panel2.Orientation = System.Windows.Controls.Orientation.Vertical;
    
            int i = 0;
            foreach (string val in elements)
            {
                RadioButton radio1 = new RadioButton();
                radio1.GroupName = "group1";
                radio1.Content = val;
                if (i == default_value)
                    radio1.IsChecked = true;
                int j = i;
                radio1.Click += (sender, args) => radio1_Checked(radio1, j);
                i++;
                panel2.Children.Add(radio1);
            }
    
            Button button1 = new Button();
            button1.Background = new SolidColorBrush(Colors.Black);
            button1.Foreground = new SolidColorBrush(Colors.White);
            button1.Opacity = 1.0;
            button1.Content = "Cancel";
            button1.Margin = new Thickness(5.0);
            button1.Click += new RoutedEventHandler(closeButton_Click);
            panel2.Children.Add(button1);
            border.Child = panel2;
    
            // Open the popup.
            p.IsOpen = true;
            p.UpdateLayout();
            border.Height = panel2.DesiredSize.Height + 5.0 * 2.0;
            border.SetValue(Canvas.TopProperty, (height - border.Height) / 2.0);
            border.SetValue(Canvas.LeftProperty, (width - border.Width) / 2.0);
            p.UpdateLayout();
        }
    
        void closeButton_Click(object sender, RoutedEventArgs e)
        {
            // Close the popup.
            p.IsOpen = false;
            if (Dismissed != null)
            {
                Dismissed(Name, false, -1);
            }
        }
    
        void radio1_Checked(object sender, int idx)
        {
            p.IsOpen = false;
            if (Dismissed != null)
            {
                Dismissed(Name, idx != oldValue, idx);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am reading a book about Javascript and jQuery and using one of the
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.