欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
WPF: ControlTemplate - Completely Swapping the UI of an Element.

WPF: ControlTemplate - Completely Swapping the UI of an Element.

Posted on3/5/2007 @ 1:22 AMin#WPF|0 comments|3376 views


This post is in continuation to an explanation on WPF Templates.

1. ControlTemplate- You use this, when you want to completely redefine the visualappearance of any control. Say, you don‘t want a radiobutton to looklike a radiobutton - you want it to look like a smiley instead. Smilingmeans Checked, and Frowning means Unchecked. You could easily acheivethis using ControlTemplate.

2. ItemsPanelTemplate -Is a rather simple kind of template, it lets you control the appearanceof the "ItemsPanel" property defined by "ItemsControl" on elements suchas ListBox or ComboBox.

3. DataTemplate- is probably the most common kind of template you will use. It letsyou change how "Content" is rendered on any control. So if you have anobject called "Customer" and you want to define a standard look andfeel for "Customer" - you‘d use DataTemplate.


We‘ve all seen a button. No not your shirt button - I‘m talking about a button on the screen - a Windows Button.

Y‘know, it‘s rectangular, with some text on it - boring as hell.What‘s up with that, heck even a M&M dispensing machine has a moreattractive button. Actually, most windows controls have a standard"look & feel". While some folks argue that there is an advantage ofthis familiarity, I would argue that there is still a learning curve -of learning computers, and understanding what a button looks like, whata checkbox looks like, so on so forth.

Here is how you‘d create a boring button in WPF -

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="100" >

 

Now, what if Iwanted to completely swap out the UI, but retain the functionality?Easy, use the Button.Template property as shown below -

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="100" >

  <Button.Template>

    <ControlTemplate>

     .. specify look and feel here ..

    </ControlTemplate>

  </Button.Template>

</Button>       

 

InsideControlTemplate, you can start specifying the look & feel of yourbutton, this could be as creative as you want - even 3d stuff. I‘mgoing to keep it simple and use a simple colorful rectangle to rendermy button -

   <ControlTemplate>

      <Rectangle RadiusX="5" RadiusY="5" Stroke="LightYellow" StrokeThickness="3" Name="myRectangle">

        <Rectangle.Fill>

          <VisualBrush Opacity="0.7">

            <VisualBrush.Visual>

              <TextBlock Name="myTextBlock" Foreground="LightYellow" Background="DarkBlue" Padding="10">Press Me!</TextBlock>

            </VisualBrush.Visual>

          </VisualBrush>

        </Rectangle.Fill>

      </Rectangle>

    </ControlTemplate>

 This causes the button to look a whole lot more attractive as shown below -

(Okay okay, this is about how creative I feel at 1 AM. But theidea being, you could use tools like Expression*.*/Zam3d to create abutton that looks like whatever you wish.)

Now the problem is, a Windows Button gives the user a feedback whenclicked. So it actually looks like a button is being clicked. How can Iacheive the same in this totally customized button? Earlier I hadblogged about "

<ControlTemplate.Triggers>

  <Trigger Property="Button.IsPressed" Value="True">

    <Setter TargetName="myRectangle" Property="Stroke" Value="LightGreen"/>

    <Setter TargetName="myTextBlock" Property="Background">

      <Setter.Value>

        <LinearGradientBrush>

          <GradientStop Offset="1" Color="DarkBlue"/>

          <GradientStop Offset="0.5" Color="Blue"/>

          <GradientStop Offset="0" Color="DarkBlue"/>

        </LinearGradientBrush>

      </Setter.Value>

    </Setter>

  </Trigger>

</ControlTemplate.Triggers>

Great, now the full button‘s XAML looks like this (font size reduced- because I know you‘re gonna copy paste this into XAMLPad or sump‘n) -

<Button HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="100" >

  <Button.Template>

    <ControlTemplate>

      <Rectangle RadiusX="5" RadiusY="5" Stroke="LightYellow" StrokeThickness="3" Name="myRectangle">

        <Rectangle.Fill>

          <VisualBrush Opacity="0.7">

            <VisualBrush.Visual>

              <TextBlock Name="myTextBlock" Foreground="LightYellow" Background="DarkBlue" Padding="10">Press Me!</TextBlock>

            </VisualBrush.Visual>

          </VisualBrush>

        </Rectangle.Fill>

      </Rectangle>

      <ControlTemplate.Triggers>

        <Trigger Property="Button.IsPressed" Value="True">

          <Setter TargetName="myRectangle" Property="Stroke" Value="LightGreen"/>

          <Setter TargetName="myTextBlock" Property="Background">

            <Setter.Value>

              <LinearGradientBrush>

                <GradientStop Offset="1" Color="DarkBlue"/>

                <GradientStop Offset="0.5" Color="Blue"/>

                <GradientStop Offset="0" Color="DarkBlue"/>

              </LinearGradientBrush>

            </Setter.Value>

          </Setter>

        </Trigger>

      </ControlTemplate.Triggers>

    </ControlTemplate>

  </Button.Template>

</Button>       

NEAT, now lets throw in some glassy effect, and run the app. 

Not Clicked -

Clicked -

NEAT! :-)

打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Vue.js 使用 ElementUI
Vue+ElementUI: 手把手教你做一個(gè)audio組件
Vue開(kāi)源:manage
Vue + Vue
WPF TabItems With Close Button
WPF 模擬UI 鍵盤(pán)錄入
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久