This is the App.xaml:
<Application x:Class="Subclases.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Subclases"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="sTB" TargetType="{x:Type FrameworkElement}"/>
<Style BasedOn="{StaticResource sTB}" TargetType="{x:Type Border}" x:Name="sB">
<Setter Property="BorderBrush" Value="{Binding Border_setters.color_border}"/>
<Setter Property="BorderThickness" Value="{Binding Border_setters.grosor_border}"/>
<Setter Property="CornerRadius" Value="{Binding Border_setters.radio_border}"/>
</Style>
<Style BasedOn="{StaticResource sTB}" TargetType="{x:Type TextBox}" x:Key="sT">
<Setter Property="Height" Value="{Binding Path=TextBox_setters.height_txt}"/>
<Setter Property="Foreground" Value="{Binding TextBox_setters.foreground_txt}"/>
<Setter Property="Background" Value="{Binding TextBox_setters.background_txt}"/>
<Setter Property="Width" Value="{Binding TextBox_setters.width_txt}"/>
<Setter Property="FontSize" Value="{Binding TextBox_setters.fontsize_txt}"/>
<Setter Property="HorizontalAlignment" Value="{Binding TextBox_setters.horizontalA_txt}"/>
<Setter Property="VerticalAlignment" Value="{Binding TextBox_setters.verticalA_txt}"/>
<Setter Property="Margin" Value="{Binding TextBox_setters.margin_txt}"/>
<Setter Property="Padding" Value="{Binding TextBox_setters.padding_txt}"/>
</Style>
<Style x:Key="prueba" TargetType="TextBox" x:Name="prueba">
<Setter Property="Width" Value="{Binding TextBox_setters.width_txt }"/>
</Style>
</Application.Resources>
I need to be able to send them the data they need so they can apply the Setters correctly. These are the classes that contain the objects that I must send to the Binding of the Setters in App.xaml.
class Border_setters
{
public string color_border = "Black";
public string grosor_border = "5";
public string radio_border = "Black";
}
class TextBox_setters
{
public int height_txt() { return 50; }
public string foreground_txt() { return "White"; }
public string background_txt() { return "Red"; }
public int width_txt() { return 200; }
public string fontsize_txt() { return "16"; }
public string horizontalA_txt() { return "Center"; }
public string verticalA_txt() { return "Center"; }
public string margin_txt() { return "10"; }
public string padding_txt() { return "10"; }
}
The reason I do this is that I will need to change the parameters with a Textbox.
I discovered how to do it very easily. First I had to add
local:()
and change the methods to constructors.I only put one because it would be unnecessary to do it with each one of those that are there.