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 9179271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:45:25+00:00 2026-06-17T17:45:25+00:00

I am writing a Windows 8 Store App (Metro / Modern?) and I am

  • 0

I am writing a Windows 8 Store App (Metro / Modern?) and I am creating a control to re-use the formatting on multiple forms. I have created some WPF apps in the past and I attempted to create a Dependency Property the same way that I did in WPF. When I put the control on a form to use it though, I can’t get any value returned.

My personControl.cs WPF class:
public partial class PersonControl : UserControl
{

    public PersonControl()
    {
        InitializeComponent();

    }

    public static readonly DependencyProperty PersonProperty = 
        DependencyProperty.Register("thisPerson", typeof(Person), typeof(PersonControl));

    public Person thisPerson
    {
        get
        {
            return (Person)GetValue(PersonProperty);
        }
        set
        {
            SetValue(PersonProperty, value);
        }
    }

}

for the windows 8 app it requires PropertyMetadata to be added — I’m assuming that this is where I am going wrong, but I haven’t been able to track down what to do instead:

public partial class PersonControl : UserControl
{

    public PersonControl()
    {
        InitializeComponent();

    }

    public static readonly DependencyProperty PersonProperty = 
        DependencyProperty.Register("thisPerson", typeof(Person), typeof(PersonControl), new PropertyMetadata(new Person()));

    public Person thisPerson
    {
        get
        {
            return (Person)GetValue(PersonProperty);
        }
        set
        {
            SetValue(PersonProperty, value);
        }
    }

}

nothing has changed in the usage or binding of the control in the XAML that I know of. I am still using sample data so I create a List(Person) and then make a listbox and bind the listbox to the List(Person).


here is the binding code:

On the usercontrol xaml:

<Grid x:Name=”PersonGrid”>
…….
<TextBox x:Name="txtFirstName" Text="{Binding Path=thisPerson.FirstName, ElementName=This}"></TextBox>

On the mainpage Xaml:

<StackPanel x:Name="layoutRoot">        
   <ListBox x:Name="myListbox">
       <ListBox.ItemTemplate>
           <DataTemplate>
                <local:PersonControl x:Name="myControl" thisPerson="{Binding Path=.}" Margin="5"></local:PersonControl>               
           </DataTemplate>
       </ListBox.ItemTemplate>
   </ListBox>

Main page code behind:

List<Person> People = new List<Person>();
… populate data … 
myListbox.ItemsSource = People;

As an additional note — when I take the contents of the UserControlXaml and put the UI elements directly into the XAML on the main page, it works fine — it is when I use the UserControl that it fails.

  • 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-06-17T17:45:26+00:00Added an answer on June 17, 2026 at 5:45 pm

    It appears that the line in XAML on the usercontrol:

    <TextBox x:Name="txtFirstName" Text="{Binding Path=thisPerson.FirstName, ElementName=This}">
    

    doesn’t work the same in Windows 8 — when I took out the reference to the ElementName and the DependencyProperty (and just let .Net figure that out on it’s own I guess?) it worked fine.

    so:

     <TextBox x:Name="txtFirstName" Text="{Binding Path=FirstName}"></TextBox>
    

    works fine and the Binding is functional now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a small .NET Windows Forms app, and I use the built-in
I'm writing a Windows Store App and I need to store some data in
I am writing a Windows Store App toy application for Windows 8. It has
I'm writing a Windows Store App. It is a share target that allows the
We are writing a Windows Store app. A lot of the data processing and
I am writing a Windows 8 Store App using JavaScript, HTML5 and CSS. On
I am writing a Windows 8 Store app using Visual Studio 2012. The main
I'm writing a Windows Store app in C#, how would one go about changing
I am writing a Windows Store app which will enale the user to search
I'm writing a windows store app and am unable to include the Moq Nuget

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.