styles

TextBlock style triggers

前提是你 提交于 2019-12-20 01:49:10
问题 I would like to combine the DisplayNames from two different ViewModels, but only IF the first is not equal to a NullObject. I could easily do this in either a converter or a parent view model, but am hoping my attempt at using DataTrigger has an easy fix. Cheers, Berryl This displays nothing at all: <TextBlock Grid.Column="2" Grid.Row="0" > <TextBlock.Inlines> <Run Text="{Binding HonorificVm.DisplayName}"/> <Run Text="{Binding PersonNameVm.DisplayName}"/> </TextBlock.Inlines> <TextBlock.Style

How to propagate styles to Hyperlinks inside a DataTemplate?

时光毁灭记忆、已成空白 提交于 2019-12-19 17:41:57
问题 I'm try to set the Foreground colour on a Hyperlink using a Style object in an ancestor's Resources , but it's not having any effect. I even used the BasedOn tip from Changing Hyperlink foreground without losing hover color, but it's not made any difference - I still get a blue hyperlink that is red on hover. Here's the XAML for my controls, including an ItemsControl whose items are shown using a hyperlink: <StackPanel Background="Red" TextElement.Foreground="White"> <StackPanel.Resources>

WPF Style: how to change GradientStop Color in Trigger

穿精又带淫゛_ 提交于 2019-12-19 17:38:58
问题 I have a Button Style: <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Path x:Name="path1" ... Data="...some data..."> <Path.Fill> <LinearGradientBrush EndPoint="0.5,-0.3" StartPoint="0.5,0.8"> <GradientStop x:Name="gs1" Color="Green" Offset="0.44"/> <GradientStop Color="Black" Offset="0.727"/> </LinearGradientBrush> </Path.Fill> </Path> <ContentPresenter ...properties... /> </Grid>

How do I make a CheckBox look like a RadioButton

核能气质少年 提交于 2019-12-19 11:16:34
问题 I wanna use a CheckBox but I want it to have the RadioButton chrome. What's the easiest way to do this? 回答1: public partial class RadioCheckBox : CheckBox {...} RadioCheckBox.xaml: <CheckBox x:Class="WpfApplication1.RadioCheckBox" ... xmlns:m="clr-namespace:WpfApplication1" > <CheckBox.Style> <Style TargetType="{x:Type m:RadioCheckBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type m:RadioCheckBox}"> <Grid> <RadioButton IsChecked="{Binding RelativeSource=

Displaying Errors, Having Controls After to Move Downwards

两盒软妹~` 提交于 2019-12-19 10:15:12
问题 So I am trying to have a message displayed when the input is invalid, suppose I want something other than a ToolTip , something that stays until the error is corrected. I tried having an ErrorTemplate <Style TargetType="{x:Type TextBox}"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <StackPanel> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder x:Name="adornedErrorElement" /> </Border> <Label Background="Red" Foreground="White" FontSize

How to create unselectable TreeViewItem in WPF

落爺英雄遲暮 提交于 2019-12-19 09:15:14
问题 I'm binding TreeView. My reason is treeview level 0 is unselectable. When i click level 0 treeviewitem, current item must be collapse and first child item must be selected. ├ Item 1 //<- level 0. this item must be unselectable ├─ Child Item 11 //<- level 1 ├─ Child Item 12 ├ Item 2 //<- level 0. When i click this item, that is automatically collapse ├─ Child Item 21 ├─ Child Item 22 How to do this using style? 回答1: I'd do it in my view model. The view model for level 0 items would have:

Can I make a WPF style take precedence over a local value?

允我心安 提交于 2019-12-19 09:10:38
问题 I have created a boolean attached property in my WPF project, and I want elements with this property set to true to display a certain way, regardless of any local local values that have been set in the XAML. From the documentation, I understand that by default, local values take precedence over both style setters and style triggers. Is it possible to create a style trigger that takes precedence over local values? 回答1: Using the technique mentioned by Erti-Chris Eelmaa in his comment on my

background issue with styles and themes

雨燕双飞 提交于 2019-12-19 08:44:09
问题 in attrs I have <attr name="bzz" format="color" /> then in theme <style name="mytheme" parent="android:Theme"> <item name="bzz">@color/aaa</item> </style> and in the code this works great tv.setBackgroundResource(R.color.aaa); but when I do this it gives me an error tv.setBackgroundResource(R.attr.bzz); I do not understand what is the problem, my logic is that I set the bzz as reference to color so that should work fine, but it does not :) it says like android.content.res.Resources

Extending android:WindowTitle

折月煮酒 提交于 2019-12-19 07:39:04
问题 I wish to extend android:WindowTitle But parent="android:WindowTitle" no longer works in newer SDKs. It's a private style What is a good public replacement for parent="android:WindowTitle" ? I am getting lost reading this thread. Any alernative way for using <style name="CustomWindowTitle" parent="android:WindowTitle"> with out machine dependent hot fixes so that my code compiles for rest of the team? 回答1: You can open android-sdk-windows\platforms\android-6\data\res\values\styles.xml and

How to remove all inherited and computed styles from an element?

久未见 提交于 2019-12-19 07:12:02
问题 The page has the following CSS: input[type=text] { display: inline; padding: 7px; background-color: #f6f6f6; font-size: 12px; letter-spacing: 1px; border: 1px solid #aac7d1; /* lots of other styles here... */ } I have many text-input elements and the following: <input type="text" id="txt1" /> And I try to apply different styles to this individual textbox (txt1) via jQuery: $('#txt1').removeClass().removeAttr('style').css({ 'background-color': '#ff0000', //lots of other styles here... }); But