Custom Control Style Question
-
I am creating a File Picker control, which will have a caption, a textbox, and a button with an image on it. Pretty straightforward. The control will live inside a controls project I have.
<Setter Property="Template"> <Setter.Value> <ControlTemplate> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding BorderThickness}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="\*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Caption}" x:Name="caption" Margin="2"/> <TextBox Grid.Column="1" x:Name="textbox" Text="{Binding File}"/> <Button Grid.Column="2" x:Name="button" Command="{Binding SelectedFileCommand}"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="button" Property="Background" Value="{StaticResource disabledBackgroundBrush}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter>
If you notice, I have defined a background brush for the textbox disabled state.
-
I am creating a File Picker control, which will have a caption, a textbox, and a button with an image on it. Pretty straightforward. The control will live inside a controls project I have.
<Setter Property="Template"> <Setter.Value> <ControlTemplate> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding BorderThickness}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="\*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Caption}" x:Name="caption" Margin="2"/> <TextBox Grid.Column="1" x:Name="textbox" Text="{Binding File}"/> <Button Grid.Column="2" x:Name="button" Command="{Binding SelectedFileCommand}"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="button" Property="Background" Value="{StaticResource disabledBackgroundBrush}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter>
If you notice, I have defined a background brush for the textbox disabled state.
I pass anything that needs custom ("team") colors, a "custom colors" (team) object at "load" time; with "primary" and "secondary" colors and FG, BG colors, that are bound to at run time. The other option is to use "dynamic" resource references; where you play with the resource (brush) that is referenced.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I pass anything that needs custom ("team") colors, a "custom colors" (team) object at "load" time; with "primary" and "secondary" colors and FG, BG colors, that are bound to at run time. The other option is to use "dynamic" resource references; where you play with the resource (brush) that is referenced.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
I don't understand that at all. Please explain
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
-
I don't understand that at all. Please explain
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.
It's probably not "MVVM".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
It's probably not "MVVM".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
Huh? That's even momre confusing
In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.