2016-07-07 59 views
1

我需要一些帮助来使用我的XAML代码。 我有这个代码。我使用每个TextBox控件中的引用的样式,这很好地工作。从另一个ResourceDictionary应用Windows.Resource中的样式XAML

xmlns:estilos="clr-namespace:Application.UtilityApplicationLayer.Recursos;assembly=UtilityApplicationLayer" 

<TextBox x:Name="Name" Style="{estilos:ApplicationWindowsResource ResourceKey=WaterMarkTextBox}"/> 
<TextBox x:Name="Middle name" Style="{estilos:ApplicationWindowsResource ResourceKey=WaterMarkTextBox}"/> 
<TextBox x:Name="Last name" Style="{estilos:ApplicationWindowsResource ResourceKey=WaterMarkTextBox}"/> 
<TextBox x:Name="Age" Style="{estilos:ApplicationWindowsResource ResourceKey=WaterMarkTextBox}"/> 

现在我想要做的是创建TextBox控件,而不直接应用每个样式。我已经这样做了,但那不起作用。 任何建议。

xmlns:estilos="clr-namespace:Application.UtilityApplicationLayer.Recursos;assembly=UtilityApplicationLayer" 

<Window.Resources> 
<ResourceDictionary> 
<Style TargetType="TextBox"> 
<Setter Property="Style" Value="{estilos:PractalisVentanasRecursos ResourceKey=WaterMarkTextBox}"/> 
</Style> 
</ResourceDictionary> 
</Window.Resources> 

<TextBox x:Name="Name" /> 
<TextBox x:Name="Middle name"/> 
<TextBox x:Name="Last name" /> 
<TextBox x:Name="Age"/> 

谢谢。

+0

你有生活在estilos UtilityApplicationLayer的ResourcesDictionary?我的意思是完整的资源字典Xaml代码? –

回答

1

尝试使用样式看起来像:

<Style TargetType="TextBox" BasedOn="{estilos:PractalisVentanasRecursos ResourceKey=WaterMarkTextBox}"/> 
+1

非常感谢,它可以帮助你。 – MagnunStalin

相关问题