wpf中:xaml中的命名空间的引入

来源:互联网 发布:网络销售计划 编辑:程序博客网 时间:2024/05/24 22:44

        在xaml中如有要使用c#数据类型,那么需要引入c#的命名空间,如需要使用String类,则需要引入String所在的命名空间。

<Window x:Class="Test2.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:sys="clr-namespace:System;assembly=mscorlib"        Title="MainWindow" Height="350" Width="525">    <Grid>                <StackPanel>            <StackPanel.Resources>                <sys:String x:Key="myString">                    lasklsdsldfslfd                </sys:String>            </StackPanel.Resources>            <TextBox x:Name="textBox1" Text="{Binding Path=Text[4],ElementName=textBox2, Mode=OneWay}"></TextBox>            <TextBox x:Name="textBox2" Text="{StaticResource ResourceKey=myString}"></TextBox>        </StackPanel>    </Grid></Window>


0 0
原创粉丝点击