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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:02:11+00:00 2026-05-22T13:02:11+00:00

In Silverlight, MVVM I have to create a property window, but I have just

  • 0

In Silverlight, MVVM I have to create a property window, but I have just a
List<AProperty> object, where AProperty is an abstract class with some child classes.

I want to bind it to a Silverlight control (but to which one?), with some conditions:

  1. some child-properties must be shown as a textbox, some as a checkbox, and some as a combobox. It comes from the dynamic type.
  2. the AProperty class has a PropertyGroup and a Name field. The order must be alphabetic (PropertyGroup > Name)

Any idea or working example?

My code:

    public abstract class AProperty {
        private String _Name;
        private String _Caption;
        private String _PropertyGroup;

        public String Name {
            get { return _Name; }
            set { _Name = value; }
        }

        public String Caption {
            get { return _Caption; }
            set { _Caption = value; }
        }

        public String PropertyGroup {
            get { return _PropertyGroup; }
            set { _PropertyGroup = value; }
        }
    }
    List<AProperty> Properties;

And the xaml:

<ListBox ItemsSource="{Binding ... Properties ...}">
  <!-- Here order the items -->
  <ListBox.ItemTemplate>
    <DataTemplate>
      <StackPanel Orientation="Horizontal">
        <TextBlock Width="250"
                    Text="{Binding Path=Caption}" />

        <!-- And here need I a textbox, or a checkbox, or a combobox anyway -->
      </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

I’ve found value converters just for a control attribute, not for a whole stackpanel content.

  • 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-22T13:02:12+00:00Added an answer on May 22, 2026 at 1:02 pm

    Thanks Jesse and Andy, here is the solution

    The converter:

    public class PropertyConverter : IValueConverter {
            public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
                Binding ValueBinding = new Binding() {
                    Source = value,
                    Path = new PropertyPath( "Value" ),
                    Mode = BindingMode.TwoWay
                };
    
                Binding EditableBinding = new Binding() {
                    Source = value,
                    Path = new PropertyPath( "Editable" ),
                    Mode = BindingMode.TwoWay
                };
    
                if( value is PropertyString ) {
                    TextBox tb = new TextBox();
                    tb.SetBinding( TextBox.TextProperty, ValueBinding );
                    tb.SetBinding( TextBox.IsEnabledProperty, EditableBinding );
    
                    return tb;
                } else if( value is PropertyBoolean ) {
                    CheckBox cb = new CheckBox();
                    cb.SetBinding( CheckBox.IsCheckedProperty, ValueBinding );
                    cb.SetBinding( CheckBox.IsEnabledProperty, EditableBinding );
    
                    return cb;
                } ....
    
                return null;
            }
    
            public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
                throw new NotImplementedException();
            }
        }
    

    And the xaml code:

    ...
    xmlns:Converters="clr-namespace:MyConverters"
    ...
    
    <UserControl.Resources>
        <Converters:PropertyConverter x:Key="PropertyInput"/>
    </UserControl.Resources>
    
    ...
    
    <ListBox ItemsSource="{Binding Path=ItemProperties.GeneralProperties}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="180" />
                                <ColumnDefinition Width="320" />
                            </Grid.ColumnDefinitions>
    
                            <TextBlock Text="{Binding Name}" Grid.Column="0" />
                            <ContentPresenter Content="{Binding Converter={StaticResource PropertyInput}}" Grid.Column="1" />
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
    

    Two artikel:
    http://shawnoster.com/blog/post/Dynamic-Icons-in-the-Silverlight-TreeView.aspx
    http://www.silverlightshow.net/items/Silverlight-2-Getting-to-the-ListBoxItems-in-a-ListBox.aspx

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

Sidebar

Related Questions

Silverlight filter/class for cloud generation? Some HLSL or just C# class for generating clouds?
I have an MVVM Silverlight 4 application that holds a list of modules (a
In silverlight-MVVM applications, we have to use some kind of mediator/even aggregator file..to commuunicate
I am new to Silverlight and have been working with Simple MVVM to create
I have wholly adopted the MVVM pattern for our silverlight app. However, some of
I have to create now a multi-screen Silverlight 4 RIA application with MVVM. Each
I have some complex requirement to create a DataTemplate for a TreeView in Silverlight.
I have a Silverlight project that uses MVVM with Prism. I followed http://www.telerik.com/help/silverlight/patterns-and-practices-eventtocommand-prism.html I
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
i'm just starting with the mvvm model in Silverlight. In step 1 i got

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.