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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:55:43+00:00 2026-05-25T02:55:43+00:00

I’m just starting out with Expression Blend, and I’m trying to create a custom

  • 0

I’m just starting out with Expression Blend, and I’m trying to create a custom UserControl that exposes a property to the control’s Properties side menu that updates the different aspects of the view. For example, I want to expose property called “Text” in Blend’s Properties side menu, that binds to a TextBlock inside the UserControl.

Here is the UserControl’s XAML:

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="XDAFacebook.XFItemGrid"
    d:DesignWidth="148" d:DesignHeight="200">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid>
            <Grid Height="148" Margin="0" VerticalAlignment="Top">
                <Image Height="148" Margin="0" Source="feeds.png" Stretch="Fill" VerticalAlignment="Bottom">
                    <Image.Clip> 
                        <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,148,148" /> 
                    </Image.Clip> 
                </Image>
                <Rectangle Fill="#00EBEBEC" Margin="0,0,0,0" Stroke="#FFB5B5B5" StrokeThickness="2" RadiusX="10" RadiusY="10"/>
            </Grid>
            <TextBlock x:Name="MainText" Height="33" Margin="8,0,11,13" TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Bottom" Foreground="#FF606060" HorizontalAlignment="Center" FontWeight="Bold" FontSize="24"/>
        </Grid>
    </Grid>
</UserControl>

And here is the codebehind for that control:

[Description("Items for Main Grid")]
public partial class XFItemGrid : UserControl
{
    public XFItemGrid()
    {
        // Required to initialize variables
        InitializeComponent();
    }

    public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", 
        typeof(string), 
        typeof(XFItemGrid), 
        new PropertyMetadata(OnTextChanged));

    private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        ((XFItemGrid)d).Text = (String)e.NewValue;
    }

    [Description("Main Text to be displayed in the control")]
    public string Text
    {
        get { return (string)GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }
}

I can see the property “Text” in the Misc section of the Properties side menu, but when I update it, nothing changes in the TextBlock.

Eventually I would like to also do the same thing with the Image Source, but that if that is another post, let me know and I’ll put that in another one.

EDIT –

Dang, I found the error….. I was seriously thinking I was going crazy! But it turns out I was never setting the property correctly.

Here is the code that needs to be changed:

    private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        ((XFItemGrid)d).Text = (String)e.NewValue;
    }

to:

    private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        ((XFItemGrid)d).MainText = (String)e.NewValue;
    }

Blah, I hope that help! Make sure you actually change the property!

  • 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-25T02:55:43+00:00Added an answer on May 25, 2026 at 2:55 am

    You should take the text property out into a model object and implement INotifyPropertyChanged for it so that when it is altered it notified all controls. With XAML not having some sort of backing model you bind to is just asking for trouble.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
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.