Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks Jesse and Andy, here is the solution</p> <p>The converter:</p> <pre><code>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(); } } </code></pre> <p>And the xaml code:</p> <pre><code>... xmlns:Converters="clr-namespace:MyConverters" ... &lt;UserControl.Resources&gt; &lt;Converters:PropertyConverter x:Key="PropertyInput"/&gt; &lt;/UserControl.Resources&gt; ... &lt;ListBox ItemsSource="{Binding Path=ItemProperties.GeneralProperties}"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="180" /&gt; &lt;ColumnDefinition Width="320" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Text="{Binding Name}" Grid.Column="0" /&gt; &lt;ContentPresenter Content="{Binding Converter={StaticResource PropertyInput}}" Grid.Column="1" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>Two artikel: <a href="http://shawnoster.com/blog/post/Dynamic-Icons-in-the-Silverlight-TreeView.aspx" rel="nofollow">http://shawnoster.com/blog/post/Dynamic-Icons-in-the-Silverlight-TreeView.aspx</a> http://www.silverlightshow.net/items/Silverlight-2-Getting-to-the-ListBoxItems-in-a-ListBox.aspx</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload