wpf中:xaml中的命名空间的引入
本文章已收录于:
- 在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>