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

  • Home
  • SEARCH
  • 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 806479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:14:59+00:00 2026-05-15T00:14:59+00:00

Since you apparently can’t create a Silverlight DataTemplate in C#, I’m trying to create

  • 0

Since you apparently can’t create a Silverlight DataTemplate in C#, I’m trying to create one in XAML. I have a converter that I need to refer to, that I have defined in C# in another namespace. I’ve tried doing this:

<UserControl.Resources>
        <DataTemplate x:Key="PriceTemplate">
            <TextBlock Text="{Binding Price, Converter={Converters:PriceConverter}}" />
        </DataTemplate>
    </UserControl.Resources>

Where Converters is an xmlns that points to the correct namespace. However, I get a compilation error that says:

Type ‘Converters:PriceConverter’ is
used like a markup extension but does
not derive from MarkupExtension.

I tried adding System.Windows.Markup.MarkupExtension as a parent to my converter, but it apparently doesn’t exist in Silverlight.

How can I refer to my converter in XAML, without having to rewrite it in XAML?

  • 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-15T00:15:00+00:00Added an answer on May 15, 2026 at 12:15 am

    You want to make a static resource first, then bind to the converter that is a static resource.

     <UserControl.Resources> 
       <conv:IntConverter x:Key="IntConverter"></conv:IntConverter> 
     </UserControl.Resources> 
     <StackPanel> 
        <TextBlock x:Name="Result" Margin="15" FontSize="20" 
                  HorizontalAlignment="Center" VerticalAlignment="Center" 
                   Text="{Binding Converter={StaticResource IntConverter}}"> 
        </TextBlock> 
     </StackPanel> 
    </Window>
    

    So the “conv:” xml namespace was registered at the top of the document like you do with custom controls:

    xmlns:conv="clr-namespace:MyFooCompany.Converters"
    

    This example is adapted from the below linked tutorial regarding the same issue for WPF:

    http://www.dev102.com/2008/07/17/wpf-binding-converter-best-practices/

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

Sidebar

Related Questions

Since there is apparently no Flash control that can accept bitmap pastes , I
Apparently you can't have a Nullable<Rectangle> in Silverlight. I'd like to know the technical
I have one main thread that does some rather CPU intensive operation. The thread
Since CS3 doesn't have a web service component, as previous versions had, is there
I figure I can either use one mail() command with a large Bcc list
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
Since both a Table Scan and a Clustered Index Scan essentially scan all records
Since Graduating from a very small school in 2006 with a badly shaped &
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
Since debate without meaningful terms is meaningless , I figured I would point at

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.