WPF 控制項中的資料繫結

來源:互聯網
上載者:User

需求:一個Slider值是0到100,控制一個Border的邊框的透明度,border中的文字標籤顯示Slider當前滑動的值

<StackPanel>

<Slider Value=10 x:name="SliderName" Maximum=100 Minimun=0/>

         <Border BorderBursh=Red BorderThickness=1 Opacity={Binding ElementName=SliderName,Path=Value,Converter={StaticResource 轉換名稱}}>

<TextBlock Text={Binding ElementName=SliderName,Path=Value,StringFormat=##\\%}>

</TextBlock>

 </Border>

</StackPanel>

在控制Border透明度時,寫了一個轉換器,因為Slider的值是從0到100,而Opactity透明度的值是0到1.

我想說的重點是StringFormat,顯示的是一個百分比,使用##佔用兩位,\\後面這兩位我還沒明白什麼意思,如果不加\\,將會顯示4位元字  ru 6204%,如此說來應該是省去後兩位的意思啦,請大家給以指正。

太痛苦了,在內網寫的代碼,外網全部要手敲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.