ããã¯-ããã§åœŒã¯-ããªãã¿ã®ã³ã³ãããŒã«ã«èŠããã§ãããã
ããã¯ãWinFormsã®å€ãå人ãšéåžžã«ãã䌌ãŠããŸãã éåžžã®ã¡ãœããã®ã·ã°ããã£ã§ãããå®å šã«äžèŽããããããããªå€æãåããŸããïŒããšãã°ãEnabledããããã£ã¯ãã¬ãã£ãã¯ã¹IsãåãåããŸããïŒã ç®ã®èŠèŠåãªããã«ã®ãã©ã¡ãŒã¿ãŒãããã³ã³ãããŒã«ã«ã¯å€ãã®èšå®ããããŸãã
ããããå°ã詳ããç¥ããXAMLã§ã€ã³ã¿ãŒãã§ã€ã¹ãæ§ç¯ããéåžžã®æ¹æ³ãåŒãåºããããšãããšãåãæ··ä¹±ãçããŸãã
ã©ãããŠïŒ ããŠããã¿ã³ã«ã¯Imageããããã£ããããŸãããïŒ åè«ã ãïŒ
åé¡ã¯ãWPFïŒããæ£ç¢ºã«ã¯ãXAMLïŒã«ã¯ã€ã³ã¿ãŒãã§ã€ã¹æ§æã®ãŸã£ããç°ãªãã€ããªãã®ãŒããããšããããšã§ãã åºæ¬çãªã³ã³ãããŒã«ã¯ãåºæ¬çãªæ©èœïŒããŒãããžãŒã§ã¯ããããªããïŒã®ã¿ãè¡šããŠããŸãã åºæ¬çãªã³ã³ãããŒã«ã®ã·ã³ãã«ãã¯ããã³ãã¬ãŒããšã¹ã¿ã€ã«ã®åŒ·åãªã¡ã«ããºã ã«ãã£ãŠçžæ®ºãããŸãã
ãµãŒãããŒãã£ã®ã³ã³ããŒãã³ãã©ã€ãã©ãªã¯ååšããŸãããã»ãšãã©ã®å Žåã圹ã«ç«ããªããã絶æçã«å€ããªã£ãŠããããé«é¡ã§ãã
å°ãåãŸã§ããã®éåžžã«åçŽãªïŒäžèŠãããšæãããïŒåé¡ã解決ããå¿ èŠã«åã³çŽé¢ããŸããã ãç»åä»ãXAMLãã¿ã³ãããWPFãã¿ã³ç»åããã¹ãããªã©ã®ã¯ãšãªã§Googleå šäœãèŠãããŸããã
ã¬ãã¥ãŒãããå€æ°ã®çµæã®äžã§ãæãããªïŒãããŠåæã«äžäŸ¿ãªïŒè§£æ±ºçãšãããæŽç·Žããã解決çã®äž¡æ¹ãæããã§ããã
å°ããªäœè«æ°1
æåã®å®éšã®åŸãXAMLãšpng圢åŒã®ã¢ã€ã³ã³ã¯äºææ§ããªãããšãæããã«ãªããŸããã çç±ã«ããŸãæéããããŸããããã®ããŒãã«ã€ããŠã¯ååãªæç®ããããŸãããæçµçã«ã¯ããŠäžå¿«ã§æ©èœããªãããšãããããŸãã åçããŒãããŠãããããšãã§ã¯ããéããããããã¢ãã¡ãŒã·ã§ã³ãèœã¡èŸŒãã§ããããã«èŠãã...
ããããåæºããªãã§ãã ãã-ãããã¯ãŒã¯äžã«ãã¯ã¿ãŒç»åã®ãªãœãŒã¹ãæ°åãšæ°çŸãããŸãã
ç§ãèŠã€ããæé«ã®ãã®ã¯SyncFusion Metro Studio 2 ïŒåºåãªãïŒã§ãã ããã¯ã1700åã®ãã¯ã¿ãŒã¢ã€ã³ã³ããããXAMLã§ãããã®ã¢ã€ã³ã³ã衚瀺ããããšãæå³ããç¡æã®è£œåã§ãã çµæã¯è€éãªèŠçŽ ã®åœ¢åŒã§ååŸããããããããã¢ã€ã³ã³èªäœã®ãžãªã¡ããªãèšè¿°ããPathã®ã¿ãã³ããŒããã ãã§ååã§ãã
ãã®èŠçŽ ã䜿çšããŠããããè¡ããŸããIcones.xamlãšããååã®ResourceDictionaryããããžã§ã¯ãã«è¿œå ããå¿ èŠãªãã¹ãŠã®ã¢ã€ã³ã³ããããžã§ã¯ãã«é 眮ããŸãã
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- Resource dictionary entries should be defined here. --> <Path x:Key="IconTriangle" x:Shared="False" Stretch="Uniform" Data="M50.25,133.5 L49.75,158.25 76,147.25 z" Fill="Black" Stroke="Black"/> </ResourceDictionary>
ããããã¢ã€ã³ã³ä»ãã®ãã¿ã³ãå®è£ ããæ¹æ³ã«æ»ããŸãããã
æåã®æãæçœãªæ¹æ³ã¯ããã©ãŒã ã³ãŒãã§ç®çã®ã³ã³ãã³ããã¿ã³ãçŽæ¥èšè¿°ããããšã§ãã
<Button HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal"> <ContentControl Width="16" Height="16" Margin="4" Content="{StaticResource IconTriangle}"/> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Button</TextBlock> </StackPanel> </Button>
ãŸãããã¹ãŠãæŽã£ãŠããããã«æããŸãã ãã¿ã³ããããã¢ã€ã³ã³ãšããã¹ãããããŸãã ãã¹ãŠããšãŠãã·ã³ãã«ã§ããã®ã¢ãããŒãã§çŸããã¹ã¿ã€ãªãã·ã¥ãªã€ã³ã¿ãŒãã§ã€ã¹ãæŽçããããšãã人ã¯ãããã«å€±æããŸãã çç±ã¯æ¬¡ã®ãšããã§ããåçŽãªã¹ã¿ã€ã«èšå®ã¯ããã©ãŒã ã³ãŒãå ã§èŠçŽ ã®ãã©ã¡ãŒã¿ãŒã®èª¬æãçŽæ¥è€è£œããããšã«ãããXAMLã®èšåŒµã«ã€ãªãããŸãã 10åã®ãã¿ã³-10åã®åäžã®èª¬æã ããã¿ã³ã®ããã¹ããç·è²ã«è²ä»ãããŸãããšããã¿ã€ãã®åçŽãªå€æŽã¯ãé¢åãªã³ããŒïŒããŒã¹ãã«ãªãããã©ãŒã ãããã«èšãã¿ãŸãã
2çªç®ã®æçœãªæ¹æ³ã¯ã Buttonãç¶æ¿ããããšã§ã
ãããŠããããªãã®ãã¿ã³ããã©ãã¯ãžã£ãã¯ã§ãããªãèªèº«ãä»ã«äœãç¥ã£ãŠããããšæžããŸããããïŒ
Buttonãç¶æ¿ãã ContentControlã® DependencyPropertyãè¿œå ããŸããããã«ãããXAMLãã©ãŒã ããã¢ã€ã³ã³ã®ã³ã³ãã³ããèšå®ã§ããŸãã å®è£ ã®è©³çŽ°ã«ã€ããŠã¯è©³ãã説æããŸããïŒä»¥äžã®ãœãŒã¹ãžã®ãªã³ã¯ããããŸãã®ã§ãããããèªãããšãã§ããŸãïŒã ãããããç§ãã¡ã¯å€ãã®æçœã§éèªæãªåé¡ãåŸãããšãã§ããŸããèšããŸã§ããªããããã¯ããŸãè¯ãåããããªããšããäºå®ã§ãã
3çªç®ã®æçœãªæ¹æ³ã¯ã UserControlãäœæããããšã§ãã
UserControlãäœæãããã®äžã«ãã¿ã³ã1ã€ã ãé 眮ããŸãã UserControl㧠DependencyPropertyãäœæããŸããããã䜿çšããŠããã¿ã³ã«ããContentControlã®ã¢ã€ã³ã³ãèšå®ããŸãã ãã®æ¹æ³ã¯ãäžåšçšããæ倧éã«é«ããã¡ãã«ã«å€ããŸãã 圌ã¯ä»¥åã®æ¹æ³ã®ã»ãšãã©ãã¹ãŠã®æ¬ ç¹ãç¶æ¿ãã圌èªèº«ã®å€ããè¿œå ããŸãã ãã©ãŒã ã³ãŒãã§ã¯ã UserControlãååŸããŸããããã¿ã³ã¯å€±ãããŸãã ç§ãã¡ã¯ãã¹ãŠã®ããããã£ãšã€ãã³ããšãšãã«å€±ããŸãã ã¢ã€ãã¢ã®èè ã¯ãéåžžã«DependencyPropertyã«ãã£ãŠå€±ããããã¹ãŠãåŒãåºãããšããå§ãããŸããäžè¬ã«ãããªãã¯ç解ããŠããŸãã äœã®ããã«æŠã£ãŠããã®ããäžæ確ã«ãªããŸãã
4çªç®ã®ã¡ãœãã-AttachedProperty
ãã®æ¹æ³ã¯ãéèªæã§æŽç·Žãããæ¹æ³ãæããŸãã å ã®èšäºã§ã¯ãèè ã¯AttachedPropertyã䜿çšããŠç»åãèšå®ããããšãææ¡ããŠããŸãã ä»åŸã¯ããã®æ¹æ³ã補åã§äœ¿çšããããã«éžæãããšèšããŸãããæã詳现ã«èª¬æããŸãã éçºæ®µéã§ããã€ãã®æ¬ ç¹ããªãããã§ã¯ãããŸããïŒä»¥äžã§èª¬æããŸãïŒããããã§ãä»ã®ãã®ãããæ°ã«å ¥ã£ãŠããŸãã ãªãªãžãã«ã§ã¯ãäœè ã¯PNGç»åã®åœ¢ã§ã¢ã€ã³ã³ã䜿çšããŠããŸãããããã¯ã¿ãŒã¢ã€ã³ã³ã䜿çšããæ¹æ³ãå€æŽãããã³ãè¿œå ããŸããã
ã ãããããªãã®çè«ã ãã®AttachedPropertyãšã¯äœã§ããïŒ
ããšãã°ãGrid.Columnããããã£ãcontrolã«èšå®ãããšãã«ãåXAMLéçºè ãAttachedããããã£ã«ééããŸããã
ç°¡åã«èšãã°ããã®èãã¯Linqã®Extensionã«å°ã䌌ãŠããŸãã å€ãä»»æã®DependencyObjectã«èšå®ã§ããããããã£ãç»é²ã§ããŸãã 次ã®ããã«ãªããŸãïŒMSDNã®äŸïŒïŒ
public class AquariumObject { public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterAttached( "IsBubbleSource", typeof(Boolean), typeof(AquariumObject), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender) ); public static void SetIsBubbleSource(UIElement element, Boolean value) { element.SetValue(IsBubbleSourceProperty, value); } public static Boolean GetIsBubbleSource(UIElement element) { return (Boolean)element.GetValue(IsBubbleSourceProperty); } }
ãã®ã³ãŒãã¯ã IsBubleSourceããããã£ãç»é²ããŸãã ãã®çµæãåãButtonãªã©ã®DependencyObjectããã®å€ã«èšå®ã§ããŸãã
<Button AquariumObject.IsBubbleSource="True">Button</Button>
ãã®ã³ãŒãã®äžè¬çãªæå³ã¯ããã¿ã³ã®IsBubbleSourceããããã£ãèšå®ãããšãå€ãèšå®ããSetIsBubbleSourceã¡ãœããã«èªåçã«å°éããããšã§ãã ããããå€ãåãåããšã GetIsBubbleSourceã¡ãœããã«å ¥ããŸãã ããã¯ãã¹ãŠèªåçã«è¡ãããSetããã³Getãšããååã®ã¡ãœãããèšè¿°ããã ãã§ãæ®ãã¯ãã©ãããã©ãŒã 次第ã§ãã
ããã»ã©å€ãã®ã³ãŒããæžãããŠããªããšããäºå®ã«ããããããã Buttonèªäœã¯ãã®ãããªæäœããç±ããå·ããããããŸãããããã¯ãèšå®ããã³èŠæ±ã§ããåå¥ã®å€ã®ãªããžããªã«ãªããŸãã ãã¡ããã èŠçŽ ãButtonã« ãã£ã¹ãããããããã³ã³ãã³ããæœåºããã³ã³ãã³ãã«å¯ŸããŠããŸããŸãªæäœãå®è¡ããSetIsBubbleSourceã¡ãœãããšGetIsBubbleSourceã¡ãœããã«ããªãããŒãªããžãã¯ãå®è£ ã§ããŸãããããããŸãæªèãããã®ã§ããã®å¿ èŠã¯ãããŸããã
å®çšçãªéšåã«å°éãã
äœè«2
ãªãªãžãã«ã§ã¯ãäœè ã¯EyeCandyã¯ã©ã¹åãšãããžã§ã¯ãã®åå空éã䜿çšããŠããŸãããé·ããããããåå空éExtãšã¯ã©ã¹åEãçç¥ãããããšãé¡ã£ãŠããŸãã
次ã®ã¯ã©ã¹ãWPFãããžã§ã¯ãã«è¿œå ããŸãã
using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Ext { public class E { public static readonly DependencyProperty IconProperty; static E() { var metadata = new FrameworkPropertyMetadata(null); IconProperty = DependencyProperty.RegisterAttached("Icon", typeof(FrameworkElement), typeof(E), metadata); } public static FrameworkElement GetIcon(DependencyObject obj) { return (FrameworkElement)obj.GetValue(IconProperty); } public static void SetIcon(DependencyObject obj, FrameworkElement value) { obj.SetValue(IconProperty, value); } } }
ããã§äœãèµ·ãã£ãŠããŸããïŒ ã¿ã€ãFrameworkFrameworkã® Attached Iconããããã£ãããã©ã«ãå€nullã§ç»é²ããŸããã
次ã«ããã¿ã³ã®ãã³ãã¬ãŒããäœæããŸãã ããã¿ãŒã³ãšã¯äœããã©ã®ããã«æ©èœããããã®èª¬æã«ã€ããŠã¯è§ŠããŸãããçªç¶ãã¿ãŒã³ãäžæãªå Žåã¯ããããã¯ãŒã¯äžã«å€ãã®æ å ±ããããŸãã
ãã®ãããStyles.xamlãšããååã®ResourceDictionaryããããžã§ã¯ãã«è¿œå ããŸãïŒãããžã§ã¯ãã«çªç¶ã¹ã¿ã€ã«ãªãœãŒã¹ããŸã ãªãå ŽåïŒã ãã®ResourceDictionary㧠ã次ã®ã³ãŒããè¿œå ããŸãã
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"> <Style x:Key="ButtonFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- Resource dictionary entries should be defined here. --> <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#F3F3F3" Offset="0"/> <GradientStop Color="#EBEBEB" Offset="0.5"/> <GradientStop Color="#DDDDDD" Offset="0.5"/> <GradientStop Color="#CDCDCD" Offset="1"/> </LinearGradientBrush> <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/> <Style TargetType="{x:Type Button}"> <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/> <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/> <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="1"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RenderDefaulted="{TemplateBinding IsDefaulted}" SnapsToDevicePixels="true"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"/> <VisualState x:Name="Pressed"/> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="IconContent"> <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <StackPanel> <ContentControl Content="{StaticResource IconTriangle}" Width="16" Height="16" x:Name="IconContent" Margin="4" RenderTransformOrigin="0.5,0.5" IsEnabled="{Binding IsEnabled, ElementName=Chrome}"> <ContentControl.Effect> <DropShadowEffect Opacity="0" BlurRadius="2"/> </ContentControl.Effect> <ContentControl.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </ContentControl.RenderTransform> </ContentControl> <TextBlock x:Name="textBlock" Margin="4" TextWrapping="Wrap" Text="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center"/> </StackPanel> </Microsoft_Windows_Themes:ButtonChrome> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="true"> <Setter Property="RenderDefaulted" TargetName="Chrome" Value="true"/> </Trigger> <Trigger Property="ToggleButton.IsChecked" Value="true"> <Setter Property="RenderPressed" TargetName="Chrome" Value="true"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="#ADADAD"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
ãã®ResourceDictionaryãšã³ããªã¯ããããžã§ã¯ãå ã®ãã¿ã³ã®ãã³ãã¬ãŒãã説æããŠããŸãã ãã®ãã³ãã¬ãŒãã¯ãWPFãã¿ã³ã®ããã©ã«ãã®å€èŠ³ãèšå®ããŸããããã®ã³ã³ãã³ãã¯åå®çŸ©ãããŸãã ã³ã³ãã³ãã¯StackPanelã§ã ãããã«ã¯ContentControlãšTextBlockãå«ãŸããŸã ã æåã®äŸãšãŸã£ããåãã§ãã ããã«ããã³ãã¬ãŒãã§ã¯ãã¢ã€ã³ã³ã«æ¬¡ã®åäœãèšå®ããŸãããã¿ã³ãIsEnabled == Falseã«èšå®ãããŠããå Žåãã¢ã€ã³ã³ã¯50ïŒ ã®éæ床ãåãåããéã¢ã¯ãã£ãã«äŒŒãŠããŸãã
ãã©ãŒã ã«4ã€ã®ã·ã³ãã«ãªãã¿ã³ãè¿œå ããŸãã ããšãã°ã次ã®ããã«ãåãã¿ã³ã«ç¬èªã®ããã¹ããå²ãåœãŠãŸãïŒ Content = "Button 1" ã
ã¢ããªã±ãŒã·ã§ã³ãèµ·åããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®åãã¿ã³ã«ããåäžã®ã¢ã€ã³ã³ã¯ãç§ãã¡ãç®æããŠãããã®ã§ã¯ãããŸãããããã§ãExt.Eã¯ã©ã¹ãšAttachedPropertyã¡ã«ããºã ãšããç§å¯ã®æŠåšãéçšããŸãã
ãããã£ãŠãStyles.xamlãªãœãŒã¹ãã¡ã€ã«ã«ç§»åããæ°ããåå空éãè¿œå ããŸã ã
xmlns:Ext="clr-namespace:Ext"
ãã®åŸãäžã«ç§»åãããã¿ã³ãã³ãã¬ãŒãã§ContentControlãäœæããããã®ã³ã³ãã³ããèšå®ãããè¡ãèŠã€ããŸãã
<ContentControl Content="{StaticResource IconTriangle}" .../>
2è¡ç®ã眮ãæããŸãã
<ContentControl Content="{Binding (Ext:E.Icon), RelativeSource={RelativeSource TemplatedParent}}" .../>
ãã®è¡ã«ããã ContentControlã¯ãã¿ã³ã®Ext.E.Iconããããã£ã«ã¢ã¯ã»ã¹ãããã®ã³ã³ãã³ããååŸããŸãã ãã®åŸãExt.E.Iconããããã£ã®å€ããã¿ã³èªäœã«èšå®ããã³ãŒããè¿œå ããŸãã ããã¯ããã¿ã³ãäœæããããã©ãŒã ã®ã³ãŒãã§å®è¡ãããŸãã
<Button Ext:E.Icon="{StaticResource IconTriangle}" Content=" 1" />
ã¢ã€ã³ã³ã®ä»ãããã¿ã³ã®ããªããã£ãããŒãžã§ã³ã®æºåãã§ããŸããã IconTriangleå€ãä»ã®ãªãœãŒã¹ã®ååã«å€æŽããããšã«ããããã¿ã³ã«ããŸããŸãªã¢ã€ã³ã³ãèšå®ã§ããŸãã åæã«ãæåã®3ã€ã®ã¡ãœãããšã¯ç°ãªãããã¿ã³ã«ãã®ã¹ã¿ã€ãªã³ã°ã®æ¬æ¥ã®æ©èœããã¹ãŠä¿æããŸãïŒ Contentã®æ§é èªäœãå€æŽããæ©èœãé€ãïŒã ãã¿ã³ã®ã³ã³ãã³ãã¯CïŒããèšå®ããããã€ãã³ããå«ããã¹ãŠã®ããããã£ã¯ãã®å Žæã«æ®ããŸããã
ããå°ãå ã«è¡ããŸããã
å®éã®ãããžã§ã¯ãã§ãã®ãã¿ã³ã䜿çšããããšãããšã次ã®ããã«ãªããŸãã
- ã¢ã€ã³ã³ã®ãµã€ãºã¯èª¿æŽã§ããŸããã
- ãã¿ã³ã®åãïŒåçŽãŸãã¯æ°Žå¹³ïŒã¯èª¿æŽã§ããŸããã
ããæ£ç¢ºã«ã¯ããã¹ãŠãã«ã¹ã¿ãã€ãºå¯èœã§ããããã³ãã¬ãŒãå ã®ã¿ãã€ãŸã ãã¹ãŠã®ãã¿ã³ãäžåºŠã«äœ¿çšã§ããŸããããã³ãã¬ãŒãã®ã¯ããŒã³äœæã¯ããããšäžäŸ¿ã§ãã ããã¯ç§ãã¡ãæŠã£ããã®ã§ã¯ãããŸããã
ã¯ã©ã¹Ext.Eãæ¡åŒµããŸãã ããã«ããã«2ã€ã®AttachedPropertyãè¿œå ããŸã
- ã¿ã€ãdoubleã® IconSize
- æ¹åã¿ã€ãæ¹å
ãœãŒã¹ã³ãŒãã¯èšäºã®æåŸã«1ã€ã®ã¢ãŒã«ã€ãã«ãããããèšäºã§Ext.Eã¯ã©ã¹ã®åæ§ã®ã¡ãœãããè€è£œããŸããã
Buttonãã³ãã¬ãŒãã§è¡ãå¿ èŠãããå€æŽã®ã¿ã説æããŸãã
ContentControlã®ãµã€ãºã¯ã IconSizeå€ã«é¢é£ä»ããããŠããŸãã
<ContentControl Content="{Binding (Ext:E.Icon), RelativeSource={RelativeSource TemplatedParent}}" Width="{Binding (Ext:E.IconSize), RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding (Ext:E.IconSize), RelativeSource={RelativeSource TemplatedParent}}" .../>
StackPanelã®æ¹åã¯ã Orientationã®å€ã«é¢é£ä»ããããŠããŸãã
<StackPanel Orientation="{Binding (Ext:E.Orientation), RelativeSource={RelativeSource TemplatedParent}}">
ãã®çµæããã¿ã³ã¯è¿œå ã®ãã©ã¡ãŒã¿ãŒãåãåãã次ã®ããã«èšè¿°ã§ããŸãã
<Button Ext:E.Icon="{StaticResource IconTriangle}" Ext:E.IconSize="32" Ext:E.Orientation="Horizontal" Content=" 1"/>
ç°¡åãªæäœã®çµæããã®ãããªåç©åãååŸã§ããŸãïŒæåã®ãã¿ã³IsEnabled = "False" ïŒïŒ
ã
æåŸã«ãå¶éã«ã€ããŠèª¬æããŸã
ãããã¯ãã¹ãŠãããã»ã¹ããã³éçºããŒã«ã«é¢é£ããŠããŸãã
-XAMLãã¶ã€ããŒVisualStudio 2010ã¯ã次ã®ãããªãã¿ã³ã®åæ§ã®èª¬æã«åå¿ããŸãã
-Blend 4ãšVisualStudio 2012ã®åäœã¯æ¹åãããŸãããã次ã®æ©èœããããŸãã
- Ext.Eã¯ã©ã¹ãå€æŽããåŸãéçºç°å¢ããªããŒãããããšããå§ãããŸãã ããããªããšãå€æŽã¯ã»ãšãã©ã®å Žåå®çŸ©ãããããã¶ã€ããŒã¯ããããã£ã®è¿œå ãŸãã¯å€æŽãååšããªãããšãèªããŸãã
- ç§ãã€ã³ã¹ããŒã«ããŠããªãã¢ã«ãŽãªãºã ã«ãããšãAttachedPropertyã䜿çšããŠãã¿ã³ã«äžããããå€ã¯ããã¶ã€ããŒã«è¡šç€ºããããã©ããã«ããããã衚瀺ãããŸãã å€ãã®å Žåã衚瀺ãããããã©ãŒã ã¯æ¬¡ã®ããã«ãªããŸãã
ãã ããããã¯Designerã®ã¿ã«é¢ä¿ããã¢ããªã±ãŒã·ã§ã³ã©ã³ã¿ã€ã ã§ã¯ãã¹ãŠãæ£åžžã«æ©èœããŸãã
ããããïŒãããŠããããïŒèªè»¢è»ã«ã€ããŠèª¬æããŸãããã2æ¥éã®æ€çŽ¢ã§ããåãå ¥ããããç¡æã®å®è£ ãèŠã€ãããªãã£ããšããäºå®ã¯ããã¹ãŠããã®é¢ã§å€§äžå€«ã§ã¯ãªãããšã瀺åããŠããŸãã
ããã«ãæšæºä»¥å€ã®æ¹æ³ã§æšæºã³ã³ãããŒã«ãæ¡åŒµããã¡ã«ããºã ã«ã€ããŠå°ãç解ããæ©äŒãããããã®ã¡ã«ããºã ã«ã¯å€ãã®ã¢ããªã±ãŒã·ã§ã³ããããŸãã
ãæž èŽããããšãããããŸããã
UPDïŒç°ãªããã¿ã³ã«åãã¢ã€ã³ã³ã䜿çšããŠåé¡ã®è§£æ±ºçãèŠã€ãã£ããšããäºå®ã«ãããèšäºãæŽæ°ãããŸããã
UPD2ïŒè³¢æãªææ¡ãããããšãããããŸãã
ãœãŒã¹ã³ãŒã
䟿å©ãªãªã³ã¯ïŒ
WPFã³ã³ãããŒã«éçº-ImageButtonãæ§ç¯ãã3ã€ã®æ¹æ³
blogs.msdn.com/b/knom/archive/2007/10/31/wpf-control-development-3-ways-to-build-an-imagebutton.aspx
æ·»ä»ããããã£ã䜿çšããŠWPFã€ã¡ãŒãžãã¿ã³ãäœæãã
www.hardcodet.net/2009/01/create-wpf-image-button-through-attached-properties
ã«ã¹ã¿ã äŸåé¢ä¿ããããã£
msdn.microsoft.com/en-us/library/ms753358.aspx
SyncFusion Metro Studio 2
www.syncfusion.com/downloads/metrostudio