Search Results

Search found 64 results on 3 pages for 'datatrigger'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Trouble animating RadialGradientBrush in WPF

    - by emddudley
    I'm trying to animate a RadialGradientBrush in my application. I get the super helpful exception: Additional information: 'System.Windows.Style' value cannot be assigned to property 'Style' of object 'System.Windows.Controls.Border'. '[Unknown]' property does not point to a DependencyObject in path '(0).(1).[0].(2)'. Error at object 'System.Windows.Style' in markup file 'Eng.Modules.Core;component/system/grid/systemgridview.xaml' Line 252 Position 51. I know it's something wrong with the indirect property targeting or partial path qualification in my DoubleAnimation's Storyboard.TargetProperty attribute. Any ideas? <Border> <Border.Resources> <RadialGradientBrush x:Key="SomeBrush"> <RadialGradientBrush.GradientStops> <GradientStop Color="White" Offset="0" /> <GradientStop Color="Gold" Offset="1" /> </RadialGradientBrush.GradientStops> </RadialGradientBrush> </Border.Resources> <Border.Style> <Style TargetType="{x:Type Border}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}" Value="True"> <Setter Property="Background" Value="{StaticResource SomeBrush}" /> <DataTrigger.EnterActions> <BeginStoryboard x:Name="SomeStoryBoard"> <Storyboard> <!-- RIGHT HERE --> <DoubleAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" From="0" To="1" Duration="0:0:1" RepeatBehavior="Forever" AutoReverse="True" /> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <RemoveStoryboard BeginStoryboardName="SomeStoryBoard" /> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </Border.Style> </Border>

    Read the article

  • xaml : Retrigger opacity animation on multiple conditions

    - by Sdry
    I have a problem figuring out how datatriggers and multidatatriggers work. I am trying to display a message, and depending on the type of message keep it displayed( + having a background), or having it fade out by a double animation on the opacity property (+ having a transparent background). My xaml view has a game object as datacontext, which has a dependency property of type GameMessage, of which the constructor looks like this: public GameMessage(bool containsMessage, string message, bool canFadeAway) { ContainsMessage = containsMessage; Message = message; CanFadeAway = canFadeAway; } pretty straight forward, I want to display the message when ContainsMessage =equals true, and trigger a fade out animation if canFadeAway equals true. But also set the background based on canFadeAway. <Canvas Name="messageCanvas" Width="300" Height="100" Style="{StaticResource fadeInOut}"> <TextBlock Name="txtMessage" Text="{Binding Path=GameMessage.Message}" Canvas.Top="25" Canvas.Left="0" Foreground="{StaticResource MessageForegroundBrush}"> </TextBlock> </Canvas> Now, the Style and triggers is where I get into trouble: <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=GameMessage.ContainsMessage}" Value="True"/> <Condition Binding="{Binding Path=GameMessage.CanFadeAway}" Value="False"/> </MultiDataTrigger.Conditions> <Setter Property="Background" Value="{StaticResource MessageBackgroundBrush}" /> <Setter Property="Opacity" Value="8" /> </MultiDataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=GameMessage.ContainsMessage}" Value="True"/> <Condition Binding="{Binding Path=GameMessage.CanFadeAway}" Value="True"/> </MultiDataTrigger.Conditions> <Setter Property="Background" Value="Transparent" /> <Setter Property="Opacity" Value="8" /> </MultiDataTrigger> <DataTrigger Binding="{Binding Path=GameMessage.CanFadeAway}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard > <Storyboard BeginTime="0:0:0" > <DoubleAnimation Storyboard.TargetProperty="Opacity" From="8" To="0" Duration="0:0:1" BeginTime="0:0:0" /> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" To="8" Duration="0:0:0.1" /> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> The problem is in resetting the opacity when the GameMessage Property ( of type GameMessage) is of type true,msg",true, and gets replaced by a GameMessage object of the same kind. The opcacity remains 0, and messages only get restored again when I have a message of kind true,"msg,false. After the animation, the opacity is 0, and where I would expect the second multidatatrigger to set it back to 8, and then have the animation performed by the Datatrigger, it doesnt. What would be the best way to get this working ?

    Read the article

  • WPF: Selecting the Target of an Animation

    - by Phil Sandler
    I am trying to create a simple (I think) animation effect based on a property change in my ViewModel. I would like the target to be a specific textblock in the control template of a custom control, which inherits from Window. From the article examples I've seen, a DataTrigger is the easiest way to accomplish this. It appears that Window.Triggers doesn't support DataTriggers, which led me to try to apply the trigger in the style. The problem I am currently having is that I can't seem to target the TextBlock (or any other child control)--what happens is which the code below is that the animation is applied to the background of the whole window. If I leave off StoryBoard.Target completely, the effect is exactly the same. Is this the right approach with the wrong syntax, or is there an easier way to accomplish this? <Style x:Key="MyWindowStyle" TargetType="{x:Type Window}"> <Setter Property="Template" Value="{StaticResource MyWindowTemplate}"/> <Style.Triggers> <DataTrigger Binding="{Binding ChangeOccurred}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard BeginTime="00:00:00" Duration="0:0:2" Storyboard.Target="{Binding RelativeSource={RelativeSource AncestorType=TextBlock}}" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"> <ColorAnimation FillBehavior="Stop" From="Black" To="Red" Duration="0:0:0.5" AutoReverse="True"/> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style>

    Read the article

  • How to parametrize WPF Style?

    - by Konstantin
    Hi! I'm looking for a simplest way to remove duplication in my WPF code. Code below is a simple traffic light with 3 lights - Red, Amber, Green. It is bound to a ViewModel that has one enum property State taking one of those 3 values. Code declaring 3 ellipses is very duplicative. Now I want to add animation so that each light fades in and out - styles will become even bigger and duplication will worsen. Is it possible to parametrize style with State and Color arguments so that I can have a single style in resources describing behavior of a light and then use it 3 times - for 'Red', 'Amber' and 'Green' lights? <UserControl.Resources> <l:TrafficLightViewModel x:Key="ViewModel" /> </UserControl.Resources> <StackPanel Orientation="Vertical" DataContext="{StaticResource ViewModel}"> <StackPanel.Resources> <Style x:Key="singleLightStyle" TargetType="{x:Type Ellipse}"> <Setter Property="StrokeThickness" Value="2" /> <Setter Property="Stroke" Value="Black" /> <Setter Property="Height" Value="{Binding Width, RelativeSource={RelativeSource Self}}" /> <Setter Property="Width" Value="60" /> <Setter Property="Fill" Value="LightGray" /> </Style> </StackPanel.Resources> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Red"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Amber"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Green"> <Setter Property="Fill" Value="Green" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> </StackPanel>

    Read the article

  • WPF: Animation Only Runs Once

    - by Phil Sandler
    Very basic (I think) animation question. My animation only runs the first time "MyProp" gets set to false. If it gets set a second time, the animation doesn't run. I know my data trigger is getting hit, as the sound DOES play. The effect I want is for the animation to run, then reset the target property back to what it was before the animation occurred (thus the FillBehavior=Stop). Do I need to reset the animation after it plays? <DataTrigger Binding="{Binding MyProp}" Value="False"> <DataTrigger.EnterActions> <SoundPlayerAction Source="/Resources/Sounds/Ding.wav"/> <BeginStoryboard> <Storyboard BeginTime="00:00:00" Duration="0:0:2" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"> <ColorAnimation FillBehavior="Stop" From="Black" To="Red" Duration="0:0:0.5" AutoReverse="True"/> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger>

    Read the article

  • WPF DataTemplate - Overlay

    - by David Ward
    I have a class that I need to provide the datatemplate for. Currently I have two datatemplates, one for when Enabled == true and one for when Enabled == false. The datatemplate for the class is actually the one below which changes the template used based on a trigger: <DataTemplate x:Key="ActionNodeTemplateSelector"> <ContentPresenter Content="{Binding}" Name="cp" /> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Enabled}" Value="True"> <Setter TargetName="cp" Property="ContentTemplate" Value="{StaticResource ActionNodeTemplate}" /> </DataTrigger> <DataTrigger Binding="{Binding Enabled}" Value="False"> <Setter TargetName="cp" Property="ContentTemplate" Value="{StaticResource ActionNodeDisabledTemplate}" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> This all works well. However, now I want to also display an image overlay if the "Completed" property is true and a different image if it is incomplete. I could easily carry on using my approach to trigger on the Completed property as well but this would double the number of templates and feels wrong. Is there a way that I could have a trigger on my DataTemplate that will allow me to overlay the correct image over the existing template which is based on the Enabled property?

    Read the article

  • UserControl as ListBoxItem and IsSelected

    - by mattjf
    I have a usercontrol that I want to use as a ListBoxItem. <ListBox.ItemTemplate> <DataTemplate> <local:MyUserControl/> </DataTemplate> </ListBox.ItemTemplate> I'd like to play a storyboard when the usercontrol is unselected. <UserControl.Resources> <Style TargetType="{x:Type UserControl}"> <Style.Triggers> <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="False"> <DataTrigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource OnMouseLeaveSB}"/> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style> </UserControl.Resources> But the storyboard is never firing. Is there a better way to do this? Edited to Add: What I am really trying to accomplish this this: When the mouse is over the UserControl, I want to play a storyboard (OnMouseEnterSB). When the mouse leaves the UserControl, I want to play another storyboard (OnMouseLeaveSB). I have all this working fine. When the UserControl is selected, however, and the mouse leaves, I do NOT want to play the storyboard. Finally, when the UserControl is unselected, I want to play the OnMouseLeaveSB storyboard.

    Read the article

  • How can I control the height of a ListView in WPF, using a complex DataTemplate with DataTriggers?

    - by Rob Perkins
    I have a ListView element with a DataTemplate for each ListViewItem defined as follows. When run, the ListView's height is not collapsed onto the items in the view, which is undesirable behavior: <DataTemplate x:Key="LicenseItemTemplate"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding company}"></TextBlock> <Grid Grid.Row="1" Style="{StaticResource HiddenWhenNotSelectedStyle}"> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <Button Grid.Row="0">ClickIt</Button> </Grid> </Grid> </DataTemplate> The second row of the outer grid has a style applied which looks like this. The purpose of the style is to : <Style TargetType="{x:Type Grid}" x:Key="HiddenWhenNotSelectedStyle" > <Style.Triggers> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem} } }" Value="False"> <Setter Property="Grid.Visibility" Value="Collapsed" /> </DataTrigger> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem} } }" Value="True"> <Setter Property="Grid.Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> The ListView renders like this: The desired appearance is this, when none of the elements are selected: ...with, of course, the ListView's height adjusting to accommodate the additional content when the second grid is made visible by selection. What can I do to get the desired behavior?

    Read the article

  • I have a WPF/Silverlight ListView whose height is unpredictable and too high. How do I control it be

    - by Rob Perkins
    I have a ListView element with a DataTemplate for each ListViewItem defined as follows. When run, the ListView's height is not collapsed onto the items in the view, which is undesirable behavior: <DataTemplate x:Key="LicenseItemTemplate"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding company}"></TextBlock> <Grid Grid.Row="1" Style="{StaticResource HiddenWhenNotSelectedStyle}"> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <Button Grid.Row="0">ClickIt</Button> </Grid> </Grid> </DataTemplate> The second row of the outer grid has a style applied which looks like this. The purpose of the style is to : <Style TargetType="{x:Type Grid}" x:Key="HiddenWhenNotSelectedStyle" > <Style.Triggers> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type ListViewItem} } }" Value="False"> <Setter Property="Grid.Visibility" Value="Collapsed" /> </DataTrigger> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type ListViewItem} } }" Value="True"> <Setter Property="Grid.Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> The ListView renders like this: The desired appearance is this, when none of the elements are selected: ...with, of course, the ListView's height adjusting to accommodate the additional content when the second grid is made visible by selection. What can I do to get the desired behavior?

    Read the article

  • User Control - dependency property to Change Image Issues

    - by mflair2000
    i'm having issues setting the Image from a dependency property. It seems like the trigger doesnt fire. I just want hide/show and image, or set the source if possible. public static readonly DependencyProperty HasSingleValueProperty = DependencyProperty.Register("HasSingleValue", typeof(bool), typeof(LevelControl), new FrameworkPropertyMetadata(false,FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public bool HasSingleValue { get { return (bool)GetValue(HasSingleValueProperty); } set { SetValue(HasSingleValueProperty, value); } } public LevelControl() { this.InitializeComponent(); //this.DataContext = this; LayoutRoot.DataContext = this; } //Control Markup <Grid x:Name="LayoutRoot"> <Image x:Name="xGreenBarClientTX" HorizontalAlignment="Stretch" Height="13" Margin="7,8.5,7,0" Stretch="Fill" VerticalAlignment="Top" Width="47" Canvas.Left="181.67" d:LayoutOverrides="Height" > <Image.Style> <Style TargetType="{x:Type Image}"> <Style.Triggers> <DataTrigger Binding="{Binding HasSingleValue}" Value="True"> <Setter Property="Opacity" Value="100"/> </DataTrigger> <DataTrigger Binding="{Binding HasSingleValue}" Value="False"> <Setter Property="Opacity" Value="0"/> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image>

    Read the article

  • Updating the foreground of a label on window active property-WPF

    - by Deb
    I have a label which shows the name of the window. I want to update the colour of the label on the IsActive property of the window using styles and triggers so that all the labels inheriting this style should exhibit the same property. Please can anyone suggest me how? I tried like this: <Style TargetType="{x:Type Label}" x:Key="HeaderLabel"> <Style.Triggers> <DataTrigger Binding="{Binding (Window.IsActive)}" Value="True"> <Setter Property="FontSize" Value="15"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontFamily" Value="Arial"/> <Setter Property="Foreground" Value="Black"/> <Setter Property="HorizontalAlignment" Value="Left"/> </DataTrigger> <DataTrigger Binding="{Binding (Window.IsActive)}" Value="False"> <Setter Property="FontSize" Value="15"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontFamily" Value="Arial"/> <Setter Property="Foreground" Value="White"/> <Setter Property="HorizontalAlignment" Value="Left"/> </DataTrigger> </Style.Triggers> </Style>

    Read the article

  • MVVM and Animations in Silverlight

    - by Aligned
    I wanted to spin an icon to show progress to my user while some content was downloading. I'm using MVVM (aren't you) and made a satisfactory Storyboard to spin the icon. However, it took longer than expected to trigger that animation from my ViewModel's property.I used a combination of the GoToState action and the DataTrigger from the Microsoft.Expression.Interactions dll as described here.Then I had problems getting it to start until I found this approach that saved the day. The DataTrigger didn't bind right away because "it doesn’t change visual state on load is because the StateTarget property of the GotoStateAction is null at the time the DataTrigger fires.". Here's my XAML, hopefully you can fill in the rest.<Image x:Name="StatusIcon" AutomationProperties.AutomationId="StatusIcon" Width="16" Height="16" Stretch="Fill" Source="inProgress.png" ToolTipService.ToolTip="{Binding StatusTooltip}"> <i:Interaction.Triggers> <utilitiesBehaviors:DataTriggerWhichFiresOnLoad Value="True" Binding="{Binding IsDownloading, Mode=OneWay, TargetNullValue=True}"> <ei:GoToStateAction StateName="Downloading" /> </utilitiesBehaviors:DataTriggerWhichFiresOnLoad> <utilitiesBehaviors:DataTriggerWhichFiresOnLoad Value="False" Binding="{Binding IsDownloading, Mode=OneWay, TargetNullValue=True}"> <ei:GoToStateAction StateName="Complete"/> </utilitiesBehaviors:DataTriggerWhichFiresOnLoad> </i:Interaction.Triggers> <Image.Projection> <PlaneProjection/> </Image.Projection> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="VisualStateGroup"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="0" To="Downloading"> <VisualTransition.GeneratedEasingFunction> <QuadraticEase EasingMode="EaseInOut"/> </VisualTransition.GeneratedEasingFunction> <Storyboard RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationZ)" Storyboard.TargetName="StatusIcon"> <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="-360"/> <EasingDoubleKeyFrame KeyTime="0:0:2" Value="-360"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualTransition> <VisualTransition From="Downloading" GeneratedDuration="0"/> </VisualStateGroup.Transitions> <VisualState x:Name="Downloading"/> <VisualState x:Name="Complete"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups></Image>MVVMAnimations.zip

    Read the article

  • Silverlight 4.0 VisualStateManager

    - by xscape
    Can anyone please help me or is there anything I miss out? the visualstate is not triggered xmlns:swi="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:esi="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity" xmlns:mei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" <my:DataGridTemplateColumn IsReadOnly="True"> <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="vsgUrgency"> <VisualState x:Name="UrgencySerious"> <Storyboard> <ColorAnimation Storyboard.TargetName="orbUrgency" Storyboard.TargetProperty="Fill" To="Red"/> </Storyboard> </VisualState> <VisualState x:Name="UrgencyNormal"> <Storyboard> <ColorAnimation Storyboard.TargetName="orbUrgency" Storyboard.TargetProperty="Fill" To="Green"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <swi:Interaction.Triggers> <esi:DataTrigger Binding="{Binding Urgency}" Value="Serious"> <mei:GoToStateAction StateName="UrgencySerious"/> </esi:DataTrigger> <esi:DataTrigger Binding="{Binding Urgency}" Value="Normal"> <mei:GoToStateAction StateName="UrgencyNormal"/> </esi:DataTrigger> </swi:Interaction.Triggers> <TextBlock Text="{Binding Urgency}"/> <Path x:Name="orbUrgency" Width="14.6566" Height="14.5449" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Fill="#FFE50A0A" Data="F1 M 9.3269,3.61737C 13.3742,3.61737 16.6552,6.87332 16.6552,10.8898C 16.6552,14.9063 13.3742,18.1623 9.3269,18.1623C 5.2796,18.1623 1.99862,14.9063 1.99862,10.8898C 1.99862,6.87332 5.27956,3.61737 9.3269,3.61737 Z "> </Path> </StackPanel> </DataTemplate> </my:DataGridTemplateColumn.CellTemplate> </my:DataGridTemplateColumn>

    Read the article

  • Displaying xaml resources dynamically?

    - by Robert
    I used Mike Swanson's illustrator to xaml converter to convert some of my images to xaml. The convert creates a viewbox that contains the image. These viewboxes I made resource files in my program. The code below shows what I'm trying to do: I have a viewmodel that has an enum variable called PrimaryWinding of type Windings. The values PrimD and PrimY of the enum select the respective PrimD and PrimY xaml files in the resources. <UserControl.Resources> <DataTemplate x:Key="PrimTrafo" DataType="{x:Type l:Windings}"> <Frame Source="{Binding}" x:Name="PART_Image" NavigationUIVisibility="Hidden"> <Frame.LayoutTransform> <ScaleTransform ScaleX="0.5" ScaleY="0.5"/> </Frame.LayoutTransform> </Frame> <DataTemplate.Triggers> <DataTrigger Binding="{Binding}" Value="PrimD"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimD.xaml" /> </DataTrigger> <DataTrigger Binding="{Binding}" Value="PrimY"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimY.xaml" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </UserControl.Resources> <!--The contentcontrol that holds the datatemplate defined above--> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <ContentControl Grid.Column="0" Content="{Binding PrimaryWinding}" ContentTemplate="{StaticResource PrimTrafo}"/> </Grid> This code works. Only I can't resize the drawings to the size of the grid cell. I added the ScaleTransform class to resize the image. Is a Frame the wrong class to hold the drawings? Should I use the ScaleTransform class to resize the drawing to the size of the cell? And how can I do that dynamically?

    Read the article

  • WPF: Once I set a property in code, it ignores XAML binding forever more... how do I prevent that?

    - by Timothy Khouri
    I have a button that has a datatrigger that is used to disable the button if a certain property is not set to true: <Button Name="ExtendButton" Click="ExtendButton_Click" Margin="0,0,0,8"> <Button.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding IsConnected}" Value="False"> <Setter Property="Button.IsEnabled" Value="False" /> </DataTrigger> </Style.Triggers> </Style> </Button.Style> That's some very simple binding, and it works perfectly. I can set "IsConnected" true and false and true and false and true and false, and I love to see my button just auto-magically become disabled, then enabled, etc. etc. However, in my Button_Click event... I want to: Disable the button (by using ExtendButton.IsEnabled = false;) Run some asynchronous code (that hits a server... takes about 1 second). Re-enable the button (by using ExtendButton.IsEnabled = true;) The problem is, the very instant that I manually set IsEnabled to either true or false... my XAML binding will never fire again. This makes me very sad :( I wish that IsEnabled was tri-state... and that true meant true, false meant false and null meant inherit. But that is not the case, so what do I do?

    Read the article

  • WPF Listbox - Empty List Display Message

    - by David Ward
    Can anyone suggest the best way to display a Textblock (with a text such as "List Empty") so that it's visibility is bound to the Items.Count. I have tried the following code and can't get it to work, so think that I must be doing it wrong. <ListBox x:Name="lstItems" ItemsSource="{Binding ListItems}"> </ListBox> <TextBlock Margin="4" FontStyle="Italic" FontSize="12" Text="List is empty" Visibility="Collapsed"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=lstItems, Path=Items.Count}" Value="0"> <Setter Property="Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock>

    Read the article

  • WPF Visibility of a UI element based on combo selection

    - by tim
    Trying to show a label only when a certain item in a combo is selected. Code should pretty much explain it. <ComboBox Name="comboMyCombo"> <ComboBoxItem>Don't show the label</ComboBoxItem> <ComboBoxItem>Show the label</ComboBoxItem> </ComboBox> <Label Visibility="Collapsed">This is my label <Label.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=comboMyCombo, Path=SelectedValue}" Value="Show the label"> <Setter Property="Label.Visibility" Value="Visible"></Setter> </DataTrigger> </Style.Triggers> </Style> </Label.Style> </Label>

    Read the article

  • xaml nested class path designer issue

    - by Vlad Bezden
    Hi, I have nested class public class Enums { public enum WindowModeEnum { Edit, New } } In my xaml I reference code: <Style.Triggers> <DataTrigger Binding="{Binding WindowMode}" Value="{x:Static Types1:Enums+WindowModeEnum.Edit}"> <Setter Property="Visibility" Value="Collapsed" /> </DataTrigger> </Style.Triggers> Code compiles and runs properly, however I can't open xaml code in design window. I am getting following error: Type 'Types1:Enums+WindowModeEnum' was not found. at MS.Internal.Metadata.ExposedTypes.ValueSerializers.StaticMemberDocumentValueSerializer.ConvertToDocumentValue(ITypeMetadata type, String value, IServiceProvider documentServices) at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlMarkupExtensionPropertyBase.get_Value() at MS.Internal.Design.DocumentModel.DocumentTrees.DocumentPropertyWrapper.get_Value() at MS.Internal.Design.DocumentModel.DocumentTrees.InMemory.InMemoryDocumentProperty..ctor(DocumentProperty property, InMemoryDocumentItem item) at MS.Internal.Design.DocumentModel.DocumentTrees.InMemory.InMemoryDocumentItem.SetUpItem(DocumentItem item) Same error exist in VS2008, VS2010. Does anybody has any idea, how to deal with it so I can open window in design mode. Thanks a lot. Sincerely, Vlad.

    Read the article

  • Validation.HasError attached property

    - by Nima
    Did I miss something? 1- Style <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Validation.HasError}" Value="true"> <Setter Property="BorderBrush" Value="Blue" /> </DataTrigger> </Style.Triggers> <Setter Property="MinWidth" Value="160" /> <Setter Property="Margin" Value="0 7 0 0"/> </Style> 2 - Viewmodel implement IDataErrorInfo 3- textBox in view <TextBox x:Name="FirstName" Text="{Binding Person.FirstName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true}"></TextBox> 3 - I use Caliburn MVVM I got " BindingExpression path error: 'Validation' property not found on 'object' ''PersonWindowViewModel' (HashCode=38783181)'. BindingExpression:Path=Validation.HasError; DataItem='PersonWindowViewModel' (HashCode=38783181); target element is 'TextBox' (Name='FirstName'); target property is 'NoTarget' (type 'Object')"S

    Read the article

  • WPF trigger on datagrid to hide/show columns according to bindings

    - by Renan
    I have a data grid like this: <DataGrid AutoGenerateColumns="False" CanUserDeleteRows="True" HorizontalScrollBarVisibility="Hidden" Margin="10,10,10,10" VerticalScrollBarVisibility="Visible" CanUserAddRows="False" ItemsSource="{Binding ListGestores}" ToolTip="Selecione uma linha e pressione DELETE para remover uma unidade."> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding TB_UNIDADE.DS_NOME_UNIDADE}" CanUserResize="False" Header="Setor" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_UNIDADE.TB_UNIDADE2.DS_NOME_UNIDADE}" CanUserResize="False" Header="Unidade" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_CONTATOS.DS_NOME}" CanUserResize="False" Header="Gestor" IsReadOnly="True" /> </DataGrid.Columns> </DataGrid> The problem is that i need to verify if the 2 column binding is null, and if it is null, i need to Hide it, and Change the Header of the column 1. I know that i can do that with Triggers, but how exactly??? I started with: <DataGrid.Triggers> <DataTrigger Binding="{Binding TB_UNIDADE.TB_UNIDADE2}" Value="{x:Null}"> <Setter Property="" Value="" /> </DataTrigger> </DataGrid.Triggers> But i don't know what setter or whatever to put ! Help me =]

    Read the article

  • XAML itemscontrol visibility

    - by Sam
    Hello, I have a ItemsControl in my XAML code. When some trigger occur i want to collapse the full itemsControl, so all the elements. <ItemsControl Name="VideoViewControl" ItemsSource="{Binding Videos}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel ItemHeight="120" ItemWidth="160" Name="wrapPanel1"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <views:VideoInMenuView /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> The trigger: <DataTrigger Value="videos" Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}, Path=DataContext.VideosEnable}"> <Setter Property="ScrollViewer.Visibility" Value="Visible" TargetName="test1" /> <Setter Property="ScrollViewer.Visibility" Value="Collapsed" TargetName="test2" /> <Setter Property="WrapPanel.Visibility" Value="Collapsed" TargetName="wrapPanel1" /> </DataTrigger> When I add the last setter the program crashes. Without this last setter it works fine but no visibility change.... What is wrong with this code? What is the write method to collapse all the elements of a ItemsControl with a trigger?

    Read the article

  • Setting ItemTemplate based on CheckBox value

    - by ph0enix
    I have a DataTemplate which contains a CheckBox and ListBox. When the CheckBox is checked, I want to change the ItemTemplate property on the ListBox to change the appearance of each item. Right now, it looks like this: <DataTemplate DataType={x:Type MyViewModel}> <DockPanel> <CheckBox DockPanel.Dock="Bottom" Content="Show Details" HorizontalAlignment="Right" IsChecked="{Binding ShowDetails}" Margin="0 5 10 5" /> <ListBox ItemsSource="{Binding Items}" ItemTemplate="{StaticResource SimpleItemTemplate}" Margin="10 0 10 5"> <ListBox.Triggers> <DataTrigger Binding="{Binding ShowDetails}" Value="True"> <Setter Property="ItemTemplate" Value="{StaticResource DetailedItemTemplate}" /> </DataTrigger> </ListBox.Triggers> </ListBox> </DockPanel> </DataTemplate> However, when I try to compile, I get the following error messages: Value 'ItemTemplate' cannot be assigned to property 'Property'. Invalid PropertyDescriptor value. and Cannot find the static member 'ItemTemplateProperty' on the type 'ContentPresenter'. I'm still fairly new to WPF, so perhaps there is something I'm not quite understanding?

    Read the article

  • WPF Image change source when button is disabled

    - by Taylor
    Hi, I'm trying to show a different image when the button is disabled. Should be easy with triggers, right?! For some reason, I have not been able to get the images to switch. I've tried setting triggers on both the image and button. What is wrong with what I have below? How can I change the image source when the button is enabled/disabled? Thanks! <Button x:Name="rleft" Command="{Binding Path=Operation}" CommandParameter="{x:Static vm:Ops.OpA}"> <Button.Content> <StackPanel> <Image Width="24" Height="24" RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True" Source="/MyAssembly;component/images/enabled.png"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=rleft, Path=Button.IsEnabled}" Value="False"> <Setter Property="Image.Source" Value="/MyAssembly;component/images/disabled.png" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> </StackPanel> </Button.Content> </Button>

    Read the article

  • WPF Collapsed Grid not Styling

    - by Eric
    So, I have a grid inside a listbox. The purpose is that when the listboxitem is selected, I want the grid to show, having the selected item expand to show more detail information. I set up a style trigger for this and it works great, except for one thing: the labels and textblocks styles are unapplied on the grid. I'm assuming this has something to do with the default state of the listboxitem being collapsed, so wpf skips the styles, I was hoping it would put them on when selected fired, but it doesn't. If I use Style="{StaticResource Mystyle}" on each label/textblock, it styles fine, it just seems to not be doing the inherited style magic like it does with visible grids elsewhere in the app. See code below, the labels don't show up bolded or anything when the grid appears. <Style TargetType="{x:Type Grid}" x:Key="ListBoxItemCollapseGrid"> <Style.Triggers> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource= { RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem} } }" Value="False"> <Setter Property="Grid.Visibility" Value="Collapsed" /> </DataTrigger> </Style.Triggers> <Style.Resources> <Style TargetType="{x:Type Label}"> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="Foreground" Value="{StaticResource BaseText}" /> <Setter Property="Padding" Value="3,0,0,0" /> </Style> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="{StaticResource BaseText}" /> </Style> </Style.Resources> </Style>

    Read the article

  • WPF DataGridRow Template - how to achieve Selected event

    - by user1809972
    I would like to override the DataGridRow template depending on the datatype of object bound to the grid. If the type is label, it just shows a Label. Otehrwise, it shows the cells. Follwing is the xaml. <DataTrigger Binding="{Binding Path=IsLabel, UpdateSourceTrigger=PropertyChanged}" Value="True"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridRow}"> <Grid> <Label HorizontalAlignment="Center" Padding="3,3,3,3" FontWeight="Bold" Content="{Binding Id}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> The grid looks ok. But, when the Label is clicked, it doesnt raise the Selection changed event for the DataGridRow. How do I achieve this behaviour? This label should just behave as any other DataGridRow(with the default template). Thanks

    Read the article

< Previous Page | 1 2 3  | Next Page >