Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..
when am trying to implement Resources tag for applying style to a Textbox.. am getting the following error: 'The resource "MyTextBoxStyle" could not be resolved'. The Xaml code for my form is as follows
<Window.Resources>
<ResourceDictionary>
<Style TargetType="{x:Type TextBox}" x:Key="MyTextBoxStyle">
<Setter Property="Effect">
<Setter.Value>
<CornerRadius BottomLeft="5"
BottomRight="5"
TopLeft="5"
TopRight="5"></CornerRadius>
</Setter.Value>
</Setter>
<Setter Property="Effect">
<Setter.Value>
<Border BorderBrush="Black" BorderThickness="2"></Border>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
and in my textbox i have used that resource as the following:
<Grid>
<TextBox x:Name="txtValues" Height="25" Width="80" BorderThickness="1" Style="{StaticResource MyTextBoxStyle}">
<Grid>

could anybody help me to resolve the error..
Posted

1 solution

The xaml you provide will complain about alot but not about a resource that cannot be resolved.

1) You're setting Effect twice in your style.
2) you're setting Effect to a CornerRadius and then a Border instance, but the property Effect is of the type Effect[^]
3) you'll need to close the TextBox tag <TextBox ... />
4) you'll need to close the Grid tag <Grid><TextBox.../></Grid>

once you cleared that up it will compile
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900