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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:37:51+00:00 2026-05-18T07:37:51+00:00

My bound contents are showed as empty string in the UI design-mode. I want

  • 0

My bound contents are showed as empty string in the UI design-mode. I want to display some faked value for those contents but I don’t know how to.

Please share if you know how to. 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-18T07:37:51+00:00Added an answer on May 18, 2026 at 7:37 am

    An easy way to get Design-time-data in Visual Studio 2010 is to use a design-datacontext. Short example with a Window and a ViewModel, For DataContext, the d:DataContext will be used in Design-mode and the StaticResource will be used in runtime. You can also use a separate ViewModel for design but in this example I will use the same ViewModel for both.

    <Window ...
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:local="clr-namespace:DesignTimeData"
            mc:Ignorable="d"            
            d:DataContext="{d:DesignInstance local:MyViewModel,
                            IsDesignTimeCreatable=True}">
        <Window.Resources>
            <local:MyViewModel x:Key="MyViewModel" />
        </Window.Resources>
        <Window.DataContext>
            <StaticResource ResourceKey="MyViewModel"/>
        </Window.DataContext>
        <StackPanel>
            <TextBox Text="{Binding MyText}"
                     Width="75"
                     Height="25"
                     Margin="6"/>
        </StackPanel>
    </Window>
    

    And in the ViewModels property MyText we check if we’re in design mode and in that case we return something else.

    public class MyViewModel : INotifyPropertyChanged
    {
        public MyViewModel()
        {
            MyText = "Runtime-Text";
        }
    
        private string m_myText;
        public string MyText
        {
            get
            {
                // Or you can use
                // DesignerProperties.GetIsInDesignMode(this)
                if (Designer.IsDesignMode)
                {
                    return "Design-Text";
                }
                return m_myText;
            }
            set
            {
                m_myText = value;
                OnPropertyChanged("MyText");
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
    

    Designer.cs, which is found here, looks like this

    public static class Designer
    {
        private static readonly bool isDesignMode;
        public static bool IsDesignMode
        {
            get { return isDesignMode; }
        }
        static Designer()
        {
            DependencyProperty prop =
                DesignerProperties.IsInDesignModeProperty;
            isDesignMode =
                (bool)DependencyPropertyDescriptor.
                    FromProperty(prop, typeof(FrameworkElement))
                          .Metadata.DefaultValue;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've bound my TextBox to a string value via Text={Binding AgeText, Mode=TwoWay} How can
I want to bound google map in android around the UK,so the user can't
I have some checkboxes bound to an array in my model. This works great,
I have a DataGridView bound to a LINQ to SQL query expression. I want
how do i clear the contents of a data grid that's bound to an
I'm having some problems displaying the contents of one NSArrayController in two windows defined
I have a simple ListView and want to sort the contents numerically or alphabetically,
Referring to UDP. Some would suggest that having a single port (and thus bound
I want to construct a TextBlock consisting of several Run elements, with their contents
Recently I've started learning about Contexts in .NET (context-bound, context-agile, message sinks, etc.). Several

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.