WPF 常用技巧代码

1.

.cs

namespace TestApp

{

class TestSource

{

publicstring Test1{ get; set; }

public string Test2{ get; set; }

}


}



public int StringWidth { get; set; }

private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Width = 840*1.5;
this.Height = 610*1.5;
//GridNormal.Margin = new Thickness(204, 52, 0, 0);
// this.Width =
TextBlock1.DataContext = this;
this.StringWidth = 5;

}


< Windowxmlns:local="using:TestApp" />

<Window.Resources>
<local:TestSource x:Key="TSource" Test1="Test1" Test2="Test2" />
</Window.Resources>

   <TextBlock Text="{Binding StringWidth}"></TextBlock>
 
   <TextBlock Text="{Binding Source={StaticResource TSource},Path=Test1}" ></TextBlock>

 
 
 
 
 
 
 
 
async与await
传统function 加上async 表示一个异步方法,
async void TestFunction()
{
      HttpClient client = new HttpClient();
      Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");
      string urlContents = await getStringTask;
int i = 0;
}
只有方法标记为async才能使用await ,当遇到await 立即退出当前TestFunction .await 结束后才会从await 处继续执行 TestFunction
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值