共用方式為


ObjectDataProvider.ConstructorParameters 屬性

定義

取得要傳遞至建構函式的參數清單。

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

屬性值

IList

要傳遞至建構函式的參數清單。 預設值是 null

範例

下列範例中反白顯示的行會使用 ObjectDataProvider 做為 物件的包裝函式 Person 。 元素 <ObjectDataProvider.ConstructorParameters> 示範如何將引數傳遞 String 至其建構函式。

<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>

備註

隱含變更此集合會導致 ObjectDataProvider 重新整理。 變更多個重新整理原因的屬性時,建議使用 DeferRefresh

XAML 屬性項目用法

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

適用於