FAQ Database Discussion Community


In Silverlight 5, how do I bind each DataGrid's row background color to one of its bound item's properties?

datagrid,datatemplate,silverlight-5.0,controltemplate,datatrigger
Please note that this question is specific to Silverlight 5. There are lots of similar questions floating around, but often they are about WPF or previous Silverlight versions. Others target Silverlight 5, but are about controls other than DataGrid. I have been unable to find an existing question that...

TwoWay Binding is not working if Binding is changed from DataTrigger

wpf,datatemplate,datatrigger,2-way-object-databinding
I have the following DataTemplate for my Tool Bar Items: <DataTemplate DataType="{x:Type viewModels:PopupContextActionViewModel}"> <Grid> <ToggleButton Name="ToggleButton"> <ContentControl Template="{Binding Icon, Converter={StaticResource NameToResourceConverter}}" Margin="5" /> </ToggleButton> <Popup Name="ContextActionPopup" StaysOpen="False" AllowsTransparency="True" IsOpen="{Binding ElementName=ToggleButton, Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <Border...

WPF DataTrigger using enum fails

c#,wpf,enums,datatrigger
The case: I have a customized ToggleButton that uses a DrawingImage to draw a hexagon to use as template background making it a hexagonally shaped toggle button. I want to change the color (Brush) and border (Pen) of the drawing so the button looks different for different purposes. There’s a...

Trigger compilation error

sql,database,oracle,error-handling,datatrigger
I need some help in creating a trigger. create or replace trigger trigger_one before insert on Funtom_timesheet for each row Declare V_id number; V_hours number; Begin Select max(timesheet_ID)+1 into v_id from Funtom_timesheet :new.timesheet_ID :=v_id; select grade_hours into V_hours from funtom_grade join funtom_employee on emp_grade = grade_id where empid = :new.timesheet_emp;...

DataTrigger on an Image that should change the Image.Source property does not work

c#,wpf,image,binding,datatrigger
I reproduced this question/answer as given below: <Button Command="Play" ToolTip="Execute Macro"> <Image DataContext="{Binding ElementName=UserControlMacroEdit}" Source="/ParametricStudySharedGui;component/Image/arrowRight32x32.png" Height="24" Width="24"> <Image.Style> <Style TargetType="{x:Type Image}"> <Style.Triggers> <DataTrigger Binding="{Binding IsMacroRunning, Converter={StaticResource FakeTransparentConverter}, Mode=OneWay}" Value="True"> <DataTrigger.Setters> <Setter...

WPF DataTrigger not working On ComboBox?

wpf,combobox,datatrigger
I've got the following pure XAML: <DockPanel> <ComboBox Name="combo" Height="24" Width="60"> <Border Background="Gray" Padding="20,10"> <Border.Style> <Style TargetType="Border"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=combo, Path=IsDropDownOpen}" Value="True"> <Setter Property="Background" Value="Red"></Setter> </DataTrigger> </Style.Triggers> </Style> </Border.Style> </Border> </ComboBox> <TextBlock Text="{Binding...

WPF ItemsControl element DataTrigger doesn`t fire after data changes

c#,wpf,colors,itemscontrol,datatrigger
I`ve got such an issue: my datatrigger doesnt change color after binded data changes. Datatrigger is on TextBlock which is ElemntTenplate for ItemsControl. My Xaml: <Grid> <Grid.RowDefinitions> <RowDefinition ></RowDefinition> <RowDefinition Height="3*"></RowDefinition> </Grid.RowDefinitions> <Grid> <Grid.RowDefinitions> <RowDefinition ></RowDefinition> <RowDefinition ></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions>...

WPF DataGrid DataGridRow Selection Border and Spacing

wpf,datagrid,border,datatrigger
I'm using the WPF DataGrid to display data and when the user selects a row, I'd like the background of the entire row to be highlighted (with a gradient) and also to have a border. I've been using the following code, which works for the most part: <Style TargetType="DataGridRow"> <Setter...

How would you bind a DataTrigger to a Child property from a resource-defined Style?

wpf,binding,styles,datatrigger
How can I style an element based on changes in child properties? I would accept a different approach, but the desired result is simply that the parent property is set a certain way as long as a a child property (IsPressed) is true. If we are styling one named item...

Dynamically set image of each node

wpf,xaml,treeview,datatemplate,datatrigger
So I have 3 levels of nodes in my TreeView: A single Root Node (should display Image1.png) Some second level nodes (should display Image2.png) Each second level node has some third-level nodes (should display Image3.png) I'm trying to use a DataTemplate to dynamically assign the display image to each node,...

Using a Dependency Property in a Data Trigger

c#,wpf,xaml,dependency-properties,datatrigger
I have the following custom control: public class AnimatedButton : Button { public enum ButtonStates { None, Busy } public ButtonStates State { get { return (ButtonStates)GetValue(StateProperty); } set { SetValue(StateProperty, value); } } // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc......

Choose Style depending on property

c#,wpf,styles,datatrigger
Is it possible to set the Style Property (of a Button for example) from within a DataTrigger on the same control? I would like to define my Default-, MouseOver- and Selected-Styles as resources to reuse them later on. However handling MouseOver (and other) events seems to be usually done by...

Datatrigger Change ImageBrush source

wpf,xaml,controltemplate,datatrigger
Currently am working on a reversi game and this is the ControlTemplate for a Stone on the board , Am using a DataTrigger to see who the Owner is for the Stone to set the button to the appropriate Image , But when I use TargetName on the setter (To...