Düzenle

Aracılığıyla paylaş


ObjectDataProvider.ConstructorParameters Property

Definition

Gets the list of parameters to pass to the constructor.

public:
 property System::Collections::IList ^ ConstructorParameters { System::Collections::IList ^ get(); };
public System.Collections.IList ConstructorParameters { get; }
member this.ConstructorParameters : System.Collections.IList
Public ReadOnly Property ConstructorParameters As IList

Property Value

The list of parameters to pass to the constructor. The default value is null.

Examples

The highlighted lines in the following example use an ObjectDataProvider as a wrapper for a Person object. The <ObjectDataProvider.ConstructorParameters> element shows how to pass a String argument to its constructor.

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:src="clr-namespace:SDKSample"
  xmlns:system="clr-namespace:System;assembly=mscorlib"
  SizeToContent="WidthAndHeight"
  Title="Simple Data Binding Sample">

  <Window.Resources>
    <ObjectDataProvider x:Key="myDataSource" ObjectType="{x:Type src:Person}">
      <ObjectDataProvider.ConstructorParameters>
        <system:String>Joe</system:String>
      </ObjectDataProvider.ConstructorParameters>
    </ObjectDataProvider>
    <Style TargetType="{x:Type Label}">
      <Setter Property="DockPanel.Dock" Value="Top"/>
      <Setter Property="FontSize" Value="12"/>
    </Style>
    <Style TargetType="{x:Type TextBox}">
      <Setter Property="Width" Value="100"/>
      <Setter Property="Height" Value="25"/>
      <Setter Property="DockPanel.Dock" Value="Top"/>
    </Style>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="Width" Value="100"/>
      <Setter Property="Height" Value="25"/>
      <Setter Property="DockPanel.Dock" Value="Top"/>
    </Style>
  </Window.Resources>

  <Border Margin="25" BorderBrush="Aqua" BorderThickness="3" Padding="8">
    <DockPanel Width="200" Height="100">
      <Label>Enter a Name:</Label>
      <TextBox>
        <TextBox.Text>
          <Binding Source="{StaticResource myDataSource}" Path="Name"
                   UpdateSourceTrigger="PropertyChanged"/>
        </TextBox.Text>
      </TextBox>

      <Label>The name you entered:</Label>
      <TextBlock Text="{Binding Source={StaticResource myDataSource}, Path=Name}"/>
    </DockPanel>
  </Border>
</Window>

Remarks

Changing this collection implicitly causes the ObjectDataProvider to refresh. When changing multiple refresh-causing properties, the use of DeferRefresh is recommended.

XAML Property Element Usage

<object>  
  <object.ConstructorParameters>  
    parameterValues  
  </object.ConstructorParameters>  
</object>  

Applies to