《Programming WPF》Samples repack

來源:互聯網
上載者:User

學習WPF,主要是通過MSDN。即使這樣,如果有一個不錯的參考書還是不錯的,可惜的是目前看來針對WPF的書籍不是很多。這本Chris Sells《Programming Windows Presentation Foundation》雖然出版時間已經一年了,但書中的內容還是適合WPF RTM版的。這本書和MSDN互相補充著學習,能起到事半功倍的效果(^_^)

對於此書的隨書源碼,本就組織得不錯。但本著學以致用的原則,“不辭辛苦”(主要是代碼整理工作比較繁瑣)把這些隨書各個章節的源碼重新整理編輯在一起,其間參考了windows sdk中SampleGallery的頁面設計布局,本想試用一下最新的Express Blend beta1,但看著現在它黑色的themes實在彆扭,最後還是用手工寫的xaml檔案。

把此書的目錄和例子編輯成一個xml檔案,片段如下:

  <ChapterTitle Name="Chapter4. DataBinding">
    <SampleTitle Name="PersonBinding" Xaml="Samples\ch4\window4.xaml" Csharp="" />
    <SampleTitle Name="MasterDataBinding" Xaml="Samples\ch4\window2.xaml" Csharp="" />
    <SampleTitle Name="ObjectPersonBinding" Xaml="Samples\ch4\window3.xaml" Csharp="" />
    <SampleTitle Name="CustomPersonBinding" Xaml="Samples\ch4\window1.xaml" Csharp="" />
    <SampleTitle Name="XmlPersonBinding" Xaml="Samples\ch4\window5.xaml" Csharp="" />    
  </ChapterTitle>

程式運行後在Application中設定動態綁定xml檔案作為DataProvider,如下:<XmlDataProvider x:Key="Book" Source="Book.xml" XPath="Book" /> 

在UI頁面中綁定不同的UI控制項的屬性,片段如下:           <Expander  Style="{StaticResource ExpanderStyler}" DataContext="{Binding Source={StaticResource Book},XPath=ChapterTitle[1]}">
             <Expander.Header>
               <TextBlock Style="{StaticResource ExpanderHeaderTextStyler}" />
             </Expander.Header>
             <ListBox Style="{StaticResource listBoxStyler}"/>
           </Expander>

最終運行如下:

更詳細的部分參見原始碼

            最後,你可以在FlazX這兒找到這本書,學習WPF的朋友大家多交流交流!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.