2 Replies - 2055 Views - Last Post: 06 September 2014 - 11:05 PM Rate Topic: -----

#1 martynball   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 21-July 14

WPF, textbox border with gradient...

Posted 06 September 2014 - 09:47 AM

I'm sure this is the wrong board, but the WPF board is read only and I can't find a more relevant board, please point me to the right board for next time.

Anyway, here is my App.xaml code, which defines some application wide styles to use throughout my application.
<Application x:Class="JamSnapsWPF.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="Loginwindow.xaml">
    <Application.Resources>
        <Style x:Key="BodyStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#E0E0E0" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="FontFamily" Value="Segoe UI"/>
        </Style>
        <Style x:Key="HeaderStyle" TargetType="Label">
            <Setter Property="Foreground" Value="Firebrick" />
            <Setter Property="FontSize" Value="30" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="FontFamily" Value="Segoe UI"/>
            <Setter Property="Margin" Value="0,0,0,20"/>
        </Style>
        <Style x:Key="InputTitle" TargetType="Label">
            <Setter Property="Foreground" Value="IndianRed"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="Margin" Value="0,10,0,0" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="VerticalAlignment" Value="Top" />
        </Style>

        <Style x:Key="InputField" TargetType="TextBox">
            <Setter Property="Background" Value="{StaticResource InputBackgroundGradient}" />
            <Setter Property="Foreground" Value="#E0E0E0" />
            <Setter Property="Padding" Value="5" />
            <Setter Property="BorderBrush" Value="{StaticResource InputBorderGradient}" />
        </Style>

        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="InputBorderGradient">
            <GradientStop Color="#FF494949" Offset="0"/>
            <GradientStop Color="#FF272727" Offset="1"/>
        </LinearGradientBrush>
        
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="InputBackgroundGradient">
            <GradientStop Color="#FF1B1B1B" Offset="0"/>
            <GradientStop Color="#FF141414" Offset="1"/>
        </LinearGradientBrush>
    </Application.Resources>
</Application>




Here is the LoginWindow xaml
<Window x:Class="JamSnapsWPF.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="LoginWindow" Height="645.075" Width="853" Topmost="True" WindowStartupLocation="CenterScreen" WindowState="Maximized" Background="#FF141414">
    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <Label Content="Login" Style="{StaticResource HeaderStyle}"/>
        <TextBlock TextWrapping="Wrap" Style="{StaticResource BodyStyle}" Width="582">
            text here....
        </TextBlock>
        <Label Content="Enter your email" Style="{StaticResource InputTitle}"/>
        <TextBox Style="{StaticResource InputField}" />
    </StackPanel>
</Window>



Getting an error when trying to give the border a gradient color from within the App.xaml.

Quote

Additional information: '{DependencyProperty.UnsetValue}' is not a valid value for property 'BorderBrush'.

This post has been edited by andrewsw: 06 September 2014 - 01:03 PM
Reason for edit:: quote tags


Is This A Good Question/Topic? 0
  • +

Replies To: WPF, textbox border with gradient...

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,228
  • Joined: 12-December 12

Re: WPF, textbox border with gradient...

Posted 06 September 2014 - 01:02 PM

Just speculating, but try moving your brush definitions earlier in the code, before you use them.




There isn't a separate WPF forum (there aren't enough questions to warrant this) so adding WPF to the topic title, as you have done, is a good idea.
Was This Post Helpful? 1
  • +
  • -

#3 martynball   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 21-July 14

Re: WPF, textbox border with gradient...

Posted 06 September 2014 - 11:05 PM

That did the job, thanks! Didn't think about that.

And okay, I will do in future threads.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1