Rendering a UI using IValueConverter using just c# code

后端 未结 1 1212
清酒与你
清酒与你 2020-12-18 11:48

I am c# and silverlight-5 beginner.

First i had to create object by deserializing an xml string. I have done that succesfully but now my next step

相关标签:
1条回答
  • 2020-12-18 12:31

    You could use Implicit Data Types for this.

    In your xaml you define a template for a certain datatype:

    <DataTemplate DataType="ComboParameter">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text={Binding Path=label}" />
                <ComboBox ItemsSource="{Binding Path=items}"/>
                <TextBlock Text="{Binding Path=unit}"/>
            </StackPanel>
    </DataTemplate>
    

    You better create different types depending on the type-element value. Another solution is to create a large template for the type Parameter, and show the appropriate elements depending on what the Parameter-type contains. But I wouldn't recommend this approach.

    Then you can use an ItemsControl to display all parameters:

    <ItemsControl ItemsSource="{Binding Path=Parameters}" />
    

    The different parameters will be rendered in different ways depending on what type it has.

    0 讨论(0)
提交回复
热议问题