i made a custom skinned textbox in App.xaml, here's the XAML: - <Style TargetType="{x:Type TextBox}">
-
-
<Setter Property ="Background">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
-
<GradientStop Color="#FFF8F8F8" Offset="0.116"/>
-
<GradientStop Color="#FFE8E8E8" Offset="0.672"/>
-
<GradientStop Color="#FFF0F0F0" Offset="0.388"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
<Setter Property="BorderBrush">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
-
<GradientStop Color="#FFD0D0D0" Offset="0.073"/>
-
<GradientStop Color="White" Offset="1"/>
-
<GradientStop Color="#FED4D4D4" Offset="0.366"/>
-
<GradientStop Color="#FED6D6D6" Offset="0.724"/>
-
<GradientStop Color="#FED0D0D0" Offset="0.108"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="{x:Type TextBox}">
-
-
<Border BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"/>
-
-
<ControlTemplate.Triggers>
-
-
<Trigger Property="IsMouseOver" Value="True">
-
-
<Setter Property="BorderBrush">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
-
<GradientStop Color="#FFA7A7A7" Offset="1"/>
-
<GradientStop Color="#FFD0D0D0"/>
-
<GradientStop Color="DarkGray" Offset="0.44"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
</Trigger>
-
-
<Trigger Property="IsFocused" Value="True">
-
-
<Setter Property="Background">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
-
<GradientStop Color="#FFF8F8F8"/>
-
<GradientStop Color="#FFF0F0F0" Offset="0.672"/>
-
<GradientStop Color="#FFF0F0F0" Offset="0.401"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
<Setter Property="BorderBrush">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
-
<GradientStop Color="#FFD0D0D0" Offset="0.073"/>
-
<GradientStop Color="#FED0D0D0" Offset="0.909"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
<Setter Property="Effect">
-
<Setter.Value>
-
<DropShadowEffect BlurRadius="48" Opacity="0.295" ShadowDepth="3" Color="#FF939393" Direction="191"/>
-
</Setter.Value>
-
</Setter>
-
-
</Trigger>
-
-
<Trigger Property="IsEnabled" Value="False">
-
-
<Setter Property="Background">
-
<Setter.Value>
-
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
-
<GradientStop Color="#4CECECEC" Offset="0"/>
-
<GradientStop Color="#FFD4D4D4" Offset="1"/>
-
</LinearGradientBrush>
-
</Setter.Value>
-
</Setter>
-
-
<Setter Property="Foreground" Value ="#FF7A7A7A"/>
-
-
<Setter Property="Effect">
-
<Setter.Value>
-
<BlurEffect Radius="2" RenderingBias="Quality"/>
-
</Setter.Value>
-
</Setter>
-
-
</Trigger>
-
-
</ControlTemplate.Triggers>
-
-
</ControlTemplate>
-
</Setter.Value>
-
</Setter>
-
</Style>
this gives all the textbox's same theme, i declare it in a Window like this: - <TextBox Height="23" HorizontalAlignment="Left" Margin="106,175,0,0" Name="textBox1" VerticalAlignment="Top" Width="201" KeyDown="textBox1_KeyDown" />
Now the problem is, i dont see the blinking cursor in textbox, nor can i type/backspace/paste/copy anything in it, i subscribed to the KeyDown event to see if it is detecting key presses, it does but it for some reason not showing the text nor the cursor, also note that if i do not include the " <Setter Property="Template">" and its childs, the textbox works fine, but then it is not completely skinned... any clues?
3 10606
The problem is the control template has no instructions for where to put the content, you have told it to draw your textbox as a border ONLY. Unfortunately, I'm not sure what is the best solution, I'm pretty new at WPF myself. I tried this variation (in place of your controltemplate border) - <Grid>
-
<Border BorderThickness="1"
-
BorderBrush="{TemplateBinding BorderBrush}"
-
Background="{TemplateBinding Background}"/>
-
<ContentPresenter HorizontalAlignment="Center"
-
VerticalAlignment="Center"/>
-
</Grid>
and this: - <Border BorderThickness="1"
-
BorderBrush="{TemplateBinding BorderBrush}"
-
Background="{TemplateBinding Background}">
-
<ContentPresenter HorizontalAlignment="Center"
-
VerticalAlignment="Center"/>
-
</Border>
and neither worked, but I'm sure this is the issue (or at least part of the issue).
Jared
Found it! - <Border BorderThickness="1"
-
BorderBrush="{TemplateBinding BorderBrush}"
-
Background="{TemplateBinding Background}">
-
<ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
-
</Border>
Let me know if this helps.
Jared
great! works but the text looks... choppy.. like... not anti alised, i dont know.. wierd
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ask |
last post by:
Hi,
I'm currently having strange problems in Visual Studio .NET.
No matter what language I'm writing my programs in, I still
can't write the sign "\" - backslash. All I get is a "Y" with
two...
|
by: John Hoffman |
last post by:
Hello
I have a routine that among other things, reads and writes some simple settings to the registry. Everything works fine. I port this program to a windows service and start it and everthing...
|
by: Paul Wilkinson |
last post by:
How can I write a method that is called when an object goes out of
scope? I've looked all over, so far I've only found discussions of how
to write methods that don't = )
|
by: Ritu |
last post by:
Hi All,
Can any body please tell me how i can write a device driver using CSharp.
Thanks,
Ritu
|
by: Leo Muller |
last post by:
Hi,
How can I write text from code behind without getting HTML tags added to it?
Up till now I used the label control. But when I call the label.text =
"something" then the HTML will output...
|
by: feng |
last post by:
..Net's .config file is supposed to replace the .ini files.
That's all fine if all I need is to read from it. But what
if I need both read and write? With .ini file, I can do
that very easily with...
|
by: Spidey |
last post by:
How can to write a c program without a main()
so i can compile and run it
|
by: Peter Olcott |
last post by:
Cab you write code directly in the Common Intermediate language? I need to
optimize a critical real-time function.
|
by: ayham |
last post by:
I can't Write to XML File using ASP.NET becouse my OS(win xp) tell me
that the user(account) that is ASP.net haven't the right to access the
file
--
ayham...
|
by: Ed Zagmoon |
last post by:
I want to write an evil AI in C++ that will be able to
evolve and become a dangerous computer-mastermind,
something like Skynet.
How can I write such an AI in C++ and how can I make
it hate...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |