2011-09-09 5 views
0

이제 맞춤형 실버 라이트 버튼을 하나 만들고 있습니다. 시각 상태를 가져 오려면 스타일이나 컨트롤 템플릿을 사용하고 싶지 않습니다. 그래서 저는 다음과 같이 작성했습니다 :스타일을 사용하지 않고 Silverlight에서 사용자 정의 버튼 만들기

<Button x:Class="MyNameSpace.MyImageButton" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

<Grid x:name="LayoutRoot"> 
    <VisualStateManager.VisualStateGroups> 
    <VisualStateGroup ... 

    </VisualStateGroup> 
    <VisualStateManager.VisualStateGroups> 
    <Border (Various border styles) 
<StackPanel x:Name="ContentPresenter" Orientation="Horizontal"> 
       <Image Source="{Binding Path=this.ImageSource}" Stretch="Fill" /> 
       <!--ContentPresenter--> 
       <ContentPresenter HorizontalAlignment="{Binding Path=this.HorizontalContentAlignment}" 
                 VerticalAlignment="{Binding Path=this.VerticalContentAlignment}" > 
         <TextBlock Text="{Binding Path=this.Content}" /> 
       </ContentPresenter> 

      </StackPanel> 
    </Border> 
</Grid> 
<Button.BorderBrush> 
..... 
<Button.BorderBrush> 
</Button> 

하지만 스타일이 제대로 작동하지 않는 것 같습니다. 기본 단추 스타일을 보여줍니다. 어떻게 작동하게 만드는지. 이미지 소스 속성도 등록했습니다. 그것도 작동하지 않습니다.

도와주세요. 미리 감사드립니다.

답변

0

실제로 Silverlight 4에서는 단추를 사용하는 경우 스타일없이 이동할 수 없습니다. 나는 많이 노력했다. 심지어 Button에서 선언 한 테두리에 색상을 지정하려고했습니다. 마지막으로 UserControl에서 파생 된 별도의 컨트롤을 사용했습니다. 그것은 나를 많이 도왔다. 확실히 그것은 버튼의 융통성을주지는 않지만, 내가 원하는 것을 나에게 주었다. 컨트롤에서 직접 비주얼 상태를 선택할 수 있습니다.

+0

이에 대한 의견이 있으시면 언제든지 문의 해주십시오. –

관련 문제