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>
이것은 내가 편집기에서 볼 것입니다 :
이것은 내가 실행중인 응용 프로그램에서 볼 것입니다 :
힌트를 주셔서 감사합니다. 생성자와 initializeComponents가 있습니다. 그것없이 응용 프로그램을 실행할 때 작동하지 않을 것 같아요 – javirs
바인딩을 제거하고 일부 텍스트를 하드 코딩하고 동일한 동작을합니다. 배경색, 테두리, 그림자, 아무 것도 없습니다. 그저 텍스트가 아닙니다. – javirs