이미지의 내용에 영향을 미치는 다양한 옵션을 포함하는 사용자 지정 단추 템플릿의 템플릿 속성을 갖고 싶습니다.템플릿 속성 옵션을 동적으로 설정하는 방법
e.e.
- 닫기
- 최대화
- 컨트롤의 사용자가 최대화 버튼의 종류를 설정하고자 그래서
을 최소화 복원, 그들은 드롭 다운에서 그것을 선택 속성 관리자에서 버튼 내에 포함 된 이미지 컨트롤의 소스가 "{DynamicResource MaximiseGlyph}"로 바뀝니다.
어떻게하면 사용자가 적절한 이미지 컨트롤 소스를 선택할 수있는 버튼의 템플릿을 선택하도록 할 수 있습니까?
<Style x:Key="WindowControlButton" TargetType="{x:Type Button}">
<Style.Resources>
<BitmapImage x:Key="RestoreGlyph" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="\Restore.png"/>
<BitmapImage x:Key="MaximiseGlyph" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="\Maximise.png"/>
<BitmapImage x:Key="CloseGlyph" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="\Close.png"/>
<BitmapImage x:Key="MinimiseGlyph" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="\Minimise.png"/>
</Style.Resources>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Ellipse Fill="Black" Opacity="0.7">
<Ellipse.Stroke>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#FFB8B8B8" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Stroke>
</Ellipse>
<Image Source="{DynamicResource RestoreGlyph}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True"/>
<Trigger Property="IsDefaulted" Value="True"/>
<Trigger Property="IsMouseOver" Value="True"/>
<Trigger Property="IsPressed" Value="True"/>
<Trigger Property="IsEnabled" Value="False"/>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
을 만드는이 튜토리얼을 따를 수 있는가? – kaj
그럼 템플릿의 속성을 4 가지 값 중 하나로 설정하고 사용자가 선택한 값을 버튼 안의 이미지의 소스 속성을 4 가지 값 중 하나로 변경하십시오. – Kian