zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

WPF方法 空间 命名 引入 XAML
2023-09-11 14:16:45 时间


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

本文章已收录于:
  •         在xaml中如有要使用c#数据类型,那么需要引入c#的命名空间,如需要使用String类,则需要引入String所在的命名空间。

  1. <Window x:Class="Test2.MainWindow"  
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.         xmlns:sys="clr-namespace:System;assembly=mscorlib"  
  5.         Title="MainWindow" Height="350" Width="525">  
  6.     <Grid>  
  7.           
  8.         <StackPanel>  
  9.             <StackPanel.Resources>  
  10.                 <sys:String x:Key="myString">  
  11.                     lasklsdsldfslfd  
  12.                 </sys:String>  
  13.             </StackPanel.Resources>  
  14.             <TextBox x:Name="textBox1" Text="{Binding Path=Text[4],ElementName=textBox2, Mode=OneWay}"></TextBox>  
  15.             <TextBox x:Name="textBox2" Text="{StaticResource ResourceKey=myString}"></TextBox>  
  16.         </StackPanel>  
  17.     </Grid>  
  18. </Window>