かずきのBlog

C#やJavaやRubyとメモ書き

目次

Blog 利用状況

ニュース

わんくまBlogが不安定になったため、前に書いてたはてなダイアリーにメインを移動します。
かずきのBlog@Hatena
技術的なネタは、こちらにも、はてなへのリンクという形で掲載しますが、雑多ネタははてなダイアリーだけに掲載することが多いと思います。
コメント
プログラマ的自己紹介
お気に入りのツール/IDE
プロフィール
経歴
広告
アクセサリ

書庫

日記カテゴリ

[WPF]ControlTemplateに挑戦 その5

その4
http://blogs.wankuma.com/kazuki/archive/2007/10/25/104006.aspx

前回は、ButtonのStyleプロパティに見た目とかに関する設定を全部押し込んだ。
これだと、ボタンの個々のプロパティに値を突っ込んでるのと大差ない。
Styleに纏めたものは、Window.ResourcesやApplication.Resourcesに入れる事で効果的に使えるようになる。
ということでWindow.Resourcesに移動させてみた。

Window1.xaml WindowのResourcesプロパティにStyleを移動させてみた版
<Window x:Class="WpfStepByStep.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ControlTemplate" Height="150" Width="150">
    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Style.Triggers>
                <!-- マウスが上に来た時の色変え  -->
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Foreground" Value="Blue" />
                </Trigger>
                <!-- マウスが押下されたときの色変え -->
                <Trigger Property="IsPressed" Value="true">
                    <Setter Property="Background" Value="Yellow" />
                </Trigger>
            </Style.Triggers>

            <!-- ボタンのテンプレート -->
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse Fill="{TemplateBinding Property=Background}"
                                 Stroke="{TemplateBinding Property=Foreground}"/>
                            <ContentPresenter
                            HorizontalAlignment="{TemplateBinding Property=HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding Property=VerticalContentAlignment}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

            <!-- フォーカス貰った時の点線も丸く -->
            <Setter Property="FocusVisualStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type Control}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Ellipse StrokeDashArray="1 2" Stroke="Red" Margin="3"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid Margin="10">
        <Button Content="Hello world" />
    </Grid>
</Window>

Window.Resourcesに移動させたことによって、Buttonの部分が非常にすっきりした。
こうすると、Window内のボタン全部が丸くなる!!
いいことだ。

ApplicationのResourcesプロパティに、このStyleを入れるとアプリケーション全体のボタンが丸くなる。
こうやって誰かデザインセンスのある人がデザインしたボタンのスタイルを入れとく事で、格好いいボタンが簡単に量産できるって寸法?

投稿日時 : 2007年10月28日 11:26

Feedback

# [WPF][C#]グラデーションしたいんだよ~ 2008/02/10 1:05 かずきのBlog

[WPF][C#]グラデーションしたいんだよ~

# burberry mens shirts 2012/10/28 13:13 http://www.burberryoutletonlineshopping.com/burber

Some really wonderful blog posts on this website , thanks for contribution.
burberry mens shirts http://www.burberryoutletonlineshopping.com/burberry-men-shirts.html

# burberry bag 2012/10/28 13:13 http://www.burberryoutletonlineshopping.com/burber

I got what you mean , thanks for posting .Woh I am glad to find this website through google. "The test and use of a man's education is that he finds pleasure in the exercise of his mind." by Carl Barzun.
burberry bag http://www.burberryoutletonlineshopping.com/burberry-tote-bags.html

# Burberry Ties 2012/10/28 13:13 http://www.burberryoutletonlineshopping.com/burber

Absolutely written articles, thanks for selective information. "The bravest thing you can do when you are not brave is to profess courage and act accordingly." by Corra Harris.
Burberry Ties http://www.burberryoutletonlineshopping.com/burberry-ties.html

# burberry womens shirts 2012/10/28 13:13 http://www.burberryoutletonlineshopping.com/burber

I like this post, enjoyed this one regards for posting .
burberry womens shirts http://www.burberryoutletonlineshopping.com/burberry-womens-shirts.html

# burberry watches for women 2012/10/28 13:13 http://www.burberryoutletonlineshopping.com/burber

Simply a smiling visitor here to share the love (:, btw outstanding design. "Make the most of your regrets... . To regret deeply is to live afresh." by Henry David Thoreau.
burberry watches for women http://www.burberryoutletonlineshopping.com/burberry-watches.html

# Nike Schehe 2012/10/30 21:38 http://www.nikefree3runschuhe.com/

Valid camaraderie foresees the requirements of more and not just laud it will be personalized.
Nike Schehe http://www.nikefree3runschuhe.com/

# clarisonic mia 2012/10/30 21:38 http://www.clarisonicmia-coupon.com/

Better not it's the perfect time more warm to get along with. Make friends that will team one to pry personally together.
clarisonic mia http://www.clarisonicmia-coupon.com/

# burberry scarf sale 2012/10/31 20:44 http://www.burberrysalehandbags.com

Its great as your other blog posts : D, appreciate it for posting . "History is a pact between the dead, the living, and the yet unborn." by Edmund Burke.
burberry scarf sale http://www.burberrysalehandbags.com

# t shirts 2012/11/02 21:34 http://www.burberrysalehandbags.com/burberry-women

Some really quality posts on this internet site , saved to bookmarks .
t shirts http://www.burberrysalehandbags.com/burberry-womens-shirts.html

# wallet 2012/11/02 21:34 http://www.burberrysalehandbags.com/burberry-walle

Some really great information, Gladiola I detected this. "It's amazing what ordinary people can do if they set out without preconceived notions." by Charles Franklin Kettering.
wallet http://www.burberrysalehandbags.com/burberry-wallets-2012.html

# Burberry Ties 2012/11/02 21:34 http://www.burberrysalehandbags.com/burberry-ties.

Very wonderful info can be found on website . "I don't know what will be used in the next world war, but the 4th will be fought with stones." by Albert Einstein.
Burberry Ties http://www.burberrysalehandbags.com/burberry-ties.html

# scarf 2012/11/02 21:34 http://www.burberrysalehandbags.com/burberry-scarf

Its fantastic as your other posts : D, thankyou for putting up. "The art of love ... is largely the art of persistence." by Albert Ellis.
scarf http://www.burberrysalehandbags.com/burberry-scarf.html

# burberry mens shirts 2012/11/03 2:21 http://www.burberryoutletscarfsale.com/burberry-me

fantastic issues altogether, you just won emblem new|a new} reader. What would you recommend in regards to your publish that you simply made some days in the past? Any certain?
burberry mens shirts http://www.burberryoutletscarfsale.com/burberry-men-shirts.html

# burberry womens shirts 2012/11/03 9:45 http://www.burberryoutletlocations.com/burberry-wo

Thanks, I have recently been looking for information about this subject for ages and yours is the greatest I have came upon so far. But, what concerning the conclusion? Are you certain concerning the supply?
burberry womens shirts http://www.burberryoutletlocations.com/burberry-womens-shirts.html

# mens shirts 2012/11/03 9:46 http://www.burberryoutletlocations.com/burberry-me

I like this post, enjoyed this one appreciate it for putting up. "We are punished by our sins, not for them." by Elbert Hubbard.
mens shirts http://www.burberryoutletlocations.com/burberry-men-shirts.html

# t shirt scarf 2012/11/03 9:46 http://www.burberryoutletlocations.com/burberry-sc

I got what you intend, appreciate it for posting .Woh I am thankful to find this website through google. "You must pray that the way be long, full of adventures and experiences." by Constantine Peter Cavafy.
t shirt scarf http://www.burberryoutletlocations.com/burberry-scarf.html

# cheap tie 2012/11/03 9:46 http://www.burberryoutletlocations.com/burberry-ti

Absolutely indited articles, thanks for entropy. "The earth was made round so we would not see too far down the road." by Karen Blixen.
cheap tie http://www.burberryoutletlocations.com/burberry-ties.html

# burberry wallets 2012/11/03 9:46 http://www.burberryoutletlocations.com/burberry-wa

I consider something really special in this site.
burberry wallets http://www.burberryoutletlocations.com/burberry-wallets-2012.html

# sac longchamp 2012/11/08 11:56 http://www.sacslongchamppascher2013.com

I see something really special in this internet site.
sac longchamp http://www.sacslongchamppascher2013.com

# passport covers 2012/11/12 2:14 http://www.bagmulberryuk.co.uk/passport-covers-c-1

Excellent website. Lots of helpful info here. I am sending it to some friends ans additionally sharing in delicious. And naturally, thanks to your sweat!
passport covers http://www.bagmulberryuk.co.uk/passport-covers-c-18.html

# dr dre headphones 2012/11/12 12:21 http://www.headphonesbeatsbydre.co.uk/

Thanks for the sensible critique. Me & my neighbor were just preparing to do some research about this. We got a grab a book from our area library but I think I learned more from this post. I am very glad to see such great info being shared freely out there.
dr dre headphones http://www.headphonesbeatsbydre.co.uk/

# cheap nike shoes 2012/11/16 10:45 http://www.superairmaxshoes.com

I like this post, enjoyed this one appreciate it for posting. "We seldom attribute common sense except to those who agree with us." by La Rochefoucauld.
cheap nike shoes http://www.superairmaxshoes.com

# Women Moncler Jackets 2012/11/16 12:03 http://www.supermonclercoats.com/women-moncler-jac

http://www.supermonclercoats.com/moncler online
Women Moncler Jackets http://www.supermonclercoats.com/women-moncler-jackets-c-4.html

# Moncler Vests 2012/11/16 12:04 http://www.supermonclercoats.com/men-moncler-vests

http://www.supermonclercoats.com/women-moncler-jackets-c-4.htmlWomen Moncler Jackets
Moncler Vests http://www.supermonclercoats.com/men-moncler-vests-c-2.html

# Men Moncler Coats 2012/11/16 12:04 http://www.supermonclercoats.com/men-moncler-jacke

http://www.supermonclercoats.com/moncler online
Men Moncler Coats http://www.supermonclercoats.com/men-moncler-jackets-c-5.html

# supra high top shoes 2012/11/16 12:34 http://www.suprafashionshoes.com

http://www.suprafashionshoes.comSupra Skytop
supra high top shoes http://www.suprafashionshoes.com

# ugg classic short 2012/11/16 14:53 http://www.superclassicboots.com/ugg-5825-short-bo

http://www.superclassicboots.com/ugg-1873-bailey-button-c-1.htmlugg bailey button
ugg classic short http://www.superclassicboots.com/ugg-5825-short-boots-c-21.html

# UGG Classic Short 2012/11/16 14:53 http://www.superclassicboots.com/ugg-5251-classic-

http://www.superclassicboots.com/ugg-5825-short-boots-c-21.htmlugg classic short
UGG Classic Short http://www.superclassicboots.com/ugg-5251-classic-short-c-11.html

# china wholesale clothing 2012/11/16 18:34 http://www.garment-fabric.net/

http://www.suprafashionshoes.comsupra high top shoes
china wholesale clothing http://www.garment-fabric.net/

# AUSTRALIA UGG 2012/11/22 22:48 http://www.bootscheapsalejp.com/

What i do not realize is in reality how you're now not really much more neatly-preferred than you may be now. You're very intelligent. You recognize thus significantly in the case of this matter, produced me individually imagine it from numerous various angles. Its like women and men aren't fascinated until it's something to accomplish with Lady gaga! Your personal stuffs outstanding. Always deal with it up!
AUSTRALIA UGG http://www.bootscheapsalejp.com/

# Christian Louboutin mens 2012/11/22 23:45 http://www.myclsale.com/christian-louboutin-mens-c

I gotta favorite this website it seems handy handy
Christian Louboutin mens http://www.myclsale.com/christian-louboutin-mens-c-6.html

# Christian Louboutin boots 2012/11/22 23:45 http://www.myclsale.com/christian-louboutin-boots-

Some truly select posts on this website , saved to my bookmarks .
Christian Louboutin boots http://www.myclsale.com/christian-louboutin-boots-c-9.html/

# Christian Louboutin Pumps 2012/11/22 23:45 http://www.myclsale.com/christian-louboutin-pumps-

I gotta bookmark this internet site it seems handy handy
Christian Louboutin Pumps http://www.myclsale.com/christian-louboutin-pumps-c-2.html

# air jordan 5 retro 2012/11/26 2:29 http://www.suparjordanshoes.com/air-jordan-5-retro

I'll immediately take hold of your rss as I can't in finding your email subscription link or newsletter service. Do you have any? Please let me understand so that I may just subscribe. Thanks.
air jordan 5 retro http://www.suparjordanshoes.com/air-jordan-5-retro-c-21.html

# air jordan 6 retro 2012/11/26 2:30 http://www.suparjordanshoes.com/air-jordan-6-retro

I'll right away grab your rss as I can't in finding your e-mail subscription hyperlink or newsletter service. Do you've any? Please allow me recognise so that I may just subscribe. Thanks.
air jordan 6 retro http://www.suparjordanshoes.com/air-jordan-6-retro-c-21.html

# 1PqvWw Very good blog article.Much thanks again. Great. 2014/07/07 23:27 canary wharf

1PqvWw Very good blog article.Much thanks again. Great.

# WzNosPRkRAjDYjQ 2014/08/27 9:11 http://crorkz.com/

1EhJ5I It is really a great and useful piece of information. I am glad that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.

# IOdfgJENwOfDpz 2014/09/09 19:58 http://www.arrasproperties.com/

Really Appreciate this article, how can I make is so that I receive an email whenever you write a new update?

# IsSEBUausWfT 2014/09/12 19:10 https://www.youtube.com/watch?v=jtXyUiBeflE

F*ckin' awesome things here. I'm very happy to see your article. Thanks a lot and i'm looking ahead to contact you. Will you kindly drop me a mail?

# 3gs5Zx Hey, thanks for the blog post.Really looking forward to read more. Fantastic. 2014/10/03 21:52 e-cigarette

3gs5Zx Hey, thanks for the blog post.Really looking forward to read more. Fantastic.

# "I just added your website on my blogroll. Really enjoyed reading through. Excellent information!" 2015/01/27 14:50 Check this out

"I just added your website on my blogroll. Really enjoyed reading through. Excellent information!"

# "Very efficiently written information. It will be helpful to anyone who usess it, together with myself." 2015/05/23 18:49 chess

"Very efficiently written information. It will be helpful to anyone who usess it, together with myself."

# "That�s kinda amazing stuff. It�s weird how sometimes random Internet surfing can get me in places like this, where really cool things can be found. I�ll be back" 2015/08/13 19:28 check this

"That?s kinda amazing stuff. It?s weird how sometimes random Internet surfing can get me in places like this, where really cool things can be found. I?ll be back"

# "You can definitely see your enthusiasm in the work you write. The world hopes for more passionate writers like you who aren�t afraid to say how they believe. Always go after your heart." 2015/10/29 15:46 las vegas carpet cleaning

"You can definitely see your enthusiasm in the work you write. The world hopes for more passionate writers like you who aren?t afraid to say how they believe. Always go after your heart."

# Tracey Biletnikoff’s life and her untimely death 2016/04/05 4:21 MelissaLuh


http://www.webcreationsuk.co.uk/
http://www.webcreationsuk.co.uk/ping-g15-driver/
http://www.webcreationsuk.co.uk/ping-g15-irons/
http://www.webcreationsuk.co.uk/ping-g20-irons/
http://www.webcreationsuk.co.uk/ping-g20-driver/
http://www.webcreationsuk.co.uk/ping-g25-driver/
http://www.webcreationsuk.co.uk/ping-g25-driver/
http://www.webcreationsuk.co.uk/ping-g25-irons/
http://www.webcreationsuk.co.uk/ping-g25-irons/
http://www.webcreationsuk.co.uk/ping-g30-driver/
http://www.webcreationsuk.co.uk/ping-g30-driver/
http://www.webcreationsuk.co.uk/ping-g30-driver/
http://www.webcreationsuk.co.uk/ping-g30-fairway-wood/
http://www.webcreationsuk.co.uk/ping-g30-hybrid/
http://www.webcreationsuk.co.uk/ping-g30-hybrid/
http://www.webcreationsuk.co.uk/ping-g30-irons/
http://www.webcreationsuk.co.uk/ping-g30-irons/
http://www.webcreationsuk.co.uk/ping-g30-irons/


# mental and emotional health issues 2016/04/05 4:21 MelissaLuh


http://www.foxcross.co.uk/
http://www.foxcross.co.uk/callaway-apex-pro-irons/
http://www.foxcross.co.uk/callaway-apex-pro-irons/
http://www.foxcross.co.uk/callaway-big-bertha-alpha-driver/
http://www.foxcross.co.uk/callaway-razr-fit-driver/
http://www.foxcross.co.uk/callaway-x-hot-irons/
http://www.foxcross.co.uk/callaway-x-24-irons/
http://www.foxcross.co.uk/callaway-x2-hot-driver/
http://www.foxcross.co.uk/callaway-x2-hot-driver/
http://www.foxcross.co.uk/callaway-x2-hot-fairway-wood/
http://www.foxcross.co.uk/callaway-x2-hot-hybrid/
http://www.foxcross.co.uk/callaway-x2-hot-irons/
http://www.foxcross.co.uk/callaway-x2-hot-irons/
http://www.foxcross.co.uk/odyssey-putters/
http://www.foxcross.co.uk/odyssey-putters/


タイトル  
名前  
Url
コメント