2017-05-16 8 views
0

ExpressionBlend에 멋진 버튼을 만들었습니다. 멋지게 작동하고 백그라운드 색상 및 기타에 대한 종속성 속성이 있습니다.디자인 타임에 WPF 컨트롤이 투명하게 표현됩니다.

Visual Studio에서 프로젝트를 만들고, dll을 가져오고, 도구 상자에 UserControl이 있고, 페이지로 끌면 trasnparent square가 나타납니다. 편집기의 모든 속성을 설정할 수 있습니다. 응용 프로그램을 실행할 수도 있고 UserControl이 모든 색을 올바르게 표시하고 있습니다.

그러나 디자이너에게는 작동하지 않습니다. 어떤 단서가 생길 수 있습니까?

나는 몇 가지 소스를 추가 할 수 있지만 ..이

.. 참고 아주 간단 물건 : 해당 UserControl의 DLL이 anycpu를 대상 플랫폼에 대해 컴파일 및 응용 프로그램이 64입니다.

public partial class InteractiveRisedButton : UserControl 
{ 
    public event EventHandler g_Clicked; 


    public string ButtonBackground 
    { 
     get { return (string)GetValue(ButtonBackgroundProperty); } 
     set { SetValue(ButtonBackgroundProperty, value); } 
    } 
    public string InnerTextContent 
    { 
     get { return (string)GetValue(InnerTextProperty); } 
     set { SetValue(InnerTextProperty, value); } 
    } 
    public static readonly DependencyProperty ButtonBackgroundProperty = 
     DependencyProperty.Register("ButtonBackground", typeof(string), typeof(InteractiveRisedButton)); 

    public static readonly DependencyProperty InnerTextProperty = 
     DependencyProperty.Register("InnerTextContent", typeof(string), typeof(InteractiveRisedButton)); 

    public InteractiveRisedButton() 
    { 
     InitializeComponent(); 
    } 
} 

XAML은 :

<UserControl x:Name="InterRisedButton" x:Class="gMaterialWPF.InteractiveRisedButton"> 
<UserControl.Resources> 
    <Style x:Key="InteractiveRisedButtonStyle" 
     ... lots of stuff here 
     Background color is binded here like: 
     <Border x:Name="area" Cursor="Hand" Background="{Binding ButtonBackground, ElementName=InterRisedButton}" BorderThickness="0"> 
</UserControl.Resources> 
<Grid> 
    <Button x:Name="button" Content="{Binding InnerTextContent, ElementName=InterRisedButton}" Margin="0" Style="{DynamicResource InteractiveRisedButtonStyle}" Click="button_Click"/> 

</Grid> 
나는 그것이 드래그 앤 드롭을 사용하여 내장 호스트 프로젝트에서

, 그것은 끝

일부 코드 .NetFW 모든 4.6.1을 기반으로 다음과 같이 입력하십시오.

<page 
    xmlns:gMaterialWPF="clr-namespace:gMaterialWPF;assembly=gMaterialWPF" 
> 

<gMaterialWPF:InteractiveRisedButton Foreground="Red" ButtonBackground="Green" InnerTextContent="HOLA!" Height="100" Margin="0,50,0,20" ClipToBounds="False"/> 

</page> 

이것은 내가 편집기에서 볼 것입니다 :

enter image description here

이것은 내가 실행중인 응용 프로그램에서 볼 것입니다 :

enter image description here

답변

0

이 코드를 모른 채 대답하기 어렵다. 컨트롤에 public 기본 생성자가 있는지 확인하고 InitializeComponent() 이 제 위치에 있는지 확인하십시오. 또한 사용자 환경을 확인하십시오. 새로운 (테스트) 프로젝트에서 사용해보십시오.

코드를 부분적으로 알고 있습니다. 재현하려고 시도했으며 제게는 다음과 같이 동작했습니다.

  • 단추를 편집 할 때 NO 단추 내용이 표시됩니다 (이 단계에서는 아직 컨테이너가 바인딩 텍스트가 아니기 때문에).
  • HOLA! 컨테이너 창 xaml을 편집 할 때 및 런타임에 표시됩니다.

내가 말할 수있는 유일한 점은 바인딩 문제입니다. FallbackValue를 사용하면

Content="{Binding InnerTextContent, ElementName=InterRisedButton, FallbackValue='Tambien hola!'}" 

을받을 수 있습니다. 바인딩이 실패하거나 특정 단계에서 여전히 발생하지 않은 경우

+0

힌트를 주셔서 감사합니다. 생성자와 initializeComponents가 있습니다. 그것없이 응용 프로그램을 실행할 때 작동하지 않을 것 같아요 – javirs

+0

바인딩을 제거하고 일부 텍스트를 하드 코딩하고 동일한 동작을합니다. 배경색, 테두리, 그림자, 아무 것도 없습니다. 그저 텍스트가 아닙니다. – javirs