[備忘]XAML中建構式傳入參數的方式

  • 496
  • 0

摘要:[備忘]XAML中建構式傳入參數的方式

<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="ObjectDataProviderProject.Window1"
	x:Name="Window"
	Title="Window1"
	Width="640" Height="480" xmlns:sys="clr-namespace:System;assembly=mscorlib"  
    xmlns:ObjectDataProviderProject="clr-namespace:ObjectDataProviderProject" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d">
	<Window.Resources>
        <ObjectDataProvider x:Key="ds" 
                            ObjectType="{x:Type ObjectDataProviderProject:DataSource}">
            <ObjectDataProvider.ConstructorParameters>
                <sys:String>this is a string</sys:String>
                <ObjectDataProviderProject:TestClass></ObjectDataProviderProject:TestClass>
            </ObjectDataProvider.ConstructorParameters>
        </ObjectDataProvider>
	</Window.Resources>
	<Grid x:Name="LayoutRoot">
	</Grid>
</Window>