Search Results

Search found 159 results on 7 pages for 'relativesource'.

Page 4/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Arbitrary Header content for each row in WPF datagrid

    - by tk
    I'm trying to put row header text based on a converter function of the index of the row. I found a way to bind to the datagridrow like below, but i can't find how to get the row index of the datagridrow object. <DataTemplate x:Key="MyRowHeaderTemplate" DataType="DataRowView"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1,0,1,0" Padding="1,0,1,0" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Item}"/> </DataTemplate> How can i get the row index and use my converter function to set the row header text?

    Read the article

  • Set ListBoxItem.IsSelected when child TextBox is Focused

    - by jpsstavares
    Hi, I have a typical MVVM scenario: I have a ListBox that is binded to a List of StepsViewModels. I define a DataTemplate so that StepViewModels are rendered as StepViews. The StepView UserControl have a set of labels and TextBoxs. What I want to do is to select the ListBoxItem that is wrapping the StepView when a textBox is focused. I've tried to create a style for my TextBoxs with the following trigger: <Trigger Property="IsFocused" Value="true"> <Setter TargetName="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}}" Property="IsSelected" Value="True"/> </Trigger> But I get an error telling me that TextBoxs don't have an IsSelected property. I now that but the Target is a ListBoxItem. How can I make it work?

    Read the article

  • databinding to self without code

    - by jcollum
    I'm building a UserControl in WPF. The control has two properties, Title and Description, that I'd like to bind to two textblocks. Seems real straightforward, and I got it working, but I'm curious about something. To get it to work I had to add this code: void CommandBlock_Loaded(object sender, RoutedEventArgs e) { this.DataContext = this; } My bindings look like this: <TextBlock Text="{Binding Title}" Width="100" ... /> <TextBlock Text="{Binding Description}" Width="100" ... /> What I'm wondering is how come I couldn't get it to work without the this.DataContext = this; and instead use DataContext="{Binding RelativeSource={RelativeSource Self}}" (in the UserControl element of the markup)? I'm sure I'm missing something about DataContexts but don't know what.

    Read the article

  • Any idea about WPF ScrollViewer to make it smooth scroolling like Android?

    - by jimi
    I have trying a simple ScrollViewer in xaml like below: <ScrollViewer Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type StackPanel}}, Path=Height}" ScrollViewer.VerticalScrollBarVisibility="Visible" CanContentScroll="True"> <DockPanel> <StackPanel Name="StackPanel1" OverridesDefaultStyle="False" Width="230" Height="803" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="23,1,0,0"> ....Something here ....Something here ....Something here </StackPanel> </DockPanel> </ScrollViewer> But my question is..is it possible for us to create any smooth scrolling likes any android or iphone using WPF? Any ideas?

    Read the article

  • Possible to implement an IsViewPortVisible dependencyproperty for an item in an ItemsControl?

    - by Matt H.
    I need to enable/disable spell checking in a richtextbox in an ItemsControl, based on whether the RichTextBox is visible in the ItemsControl's Scrollviewer. I think the route is to implement an IsViewPortVisible dependency property and wire an event handler for a changed event... I found this article that describes the lengthy process for determining if an item is in the viewport: http://social.msdn.microsoft.com/Forums/en/wpf/thread/e6ccfec3-3dc0-4702-9d0d-1cfa55ecfc90 Any ideas on where to start? I'm familiar with implementing my own dependency property for the sake of simple bindings (integers, strings, etc...). I have no idea how to undergo something like this though) This is the end result I'm hoping for: <DataTemplate> <Grid> ...Stuff in the Grid <local:CustomRichTextBox SpellCheck.IsEnabled={Binding RelativeSource={RelativeSource Self}, Path=IsViewPortVisible}/> </Grid> </DataTemplate> Help will be EXTREMELY appreciated... you'll be saving me about 500MB in memory consumption while the program is running!!!! :)

    Read the article

  • Why the data binding in this validation example works in WPF?

    - by MartyIX
    I'm wondering how exactly the XAML sample (MSDN sample) works: <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style> Questions: (Validation.Errors)[0].ErrorContent - Is this code somehow checked by WPF? Because Validation.Errors may be an empty collection and in ordinary C# code this code may throw an exception. If this data-binding returns null for valid input - the null value is then casted to empty string (in a text control for example)? The index 0 corresponds to the first error message. How can I return more error messages from Validate method? Thank you for responses!

    Read the article

  • WPF animation: binding to the "To" attribute of storyboard animation.

    - by bozalina
    Hi, I'm trying to create a button that behaves similarly to the "slide" button on the iPhone. I have an animation that adjusts the position and width of the button, but I want these values to be based on the text used in the control. Currently, they're hardcoded. Here's my working XAML, so far: <CheckBox x:Class="Smt.Controls.SlideCheckBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Smt.Controls" xmlns:System.Windows="clr-namespace:System.Windows;assembly=PresentationCore" Name="SliderCheckBox" mc:Ignorable="d"> <CheckBox.Resources> <System.Windows:Duration x:Key="AnimationTime">0:0:0.2</System.Windows:Duration> <Storyboard x:Key="OnChecking"> <DoubleAnimation Storyboard.TargetName="CheckButton" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)" Duration="{StaticResource AnimationTime}" To="40" /> <DoubleAnimation Storyboard.TargetName="CheckButton" Storyboard.TargetProperty="(Button.Width)" Duration="{StaticResource AnimationTime}" To="41" /> </Storyboard> <Storyboard x:Key="OnUnchecking"> <DoubleAnimation Storyboard.TargetName="CheckButton" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)" Duration="{StaticResource AnimationTime}" To="0" /> <DoubleAnimation Storyboard.TargetName="CheckButton" Storyboard.TargetProperty="(Button.Width)" Duration="{StaticResource AnimationTime}" To="40" /> </Storyboard> <Style x:Key="SlideCheckBoxStyle" TargetType="{x:Type local:SlideCheckBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:SlideCheckBox}"> <Canvas> <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True" VerticalAlignment="Center" HorizontalAlignment="Center" /> <Canvas> <!--Background--> <Rectangle Width="{Binding ElementName=ButtonText, Path=ActualWidth}" Height="{Binding ElementName=ButtonText, Path=ActualHeight}" Fill="LightBlue" /> </Canvas> <Canvas> <!--Button--> <Button Width="{Binding ElementName=CheckedText, Path=ActualWidth}" Height="{Binding ElementName=ButtonText, Path=ActualHeight}" Name="CheckButton" Command="{x:Static local:SlideCheckBox.SlideCheckBoxClicked}"> <Button.RenderTransform> <TransformGroup> <TranslateTransform /> </TransformGroup> </Button.RenderTransform> </Button> </Canvas> <Canvas> <!--Text--> <StackPanel Name="ButtonText" Orientation="Horizontal" IsHitTestVisible="False"> <Grid Name="CheckedText"> <Label Margin="7 0" Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SlideCheckBox}}, Path=CheckedText}" /> </Grid> <Grid Name="UncheckedText" HorizontalAlignment="Right"> <Label Margin="7 0" Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SlideCheckBox}}, Path=UncheckedText}" /> </Grid> </StackPanel> </Canvas> </Canvas> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource OnChecking}" /> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard Storyboard="{StaticResource OnUnchecking}" /> </Trigger.ExitActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </CheckBox.Resources> <CheckBox.CommandBindings> <CommandBinding Command="{x:Static local:SlideCheckBox.SlideCheckBoxClicked}" Executed="OnSlideCheckBoxClicked" /> </CheckBox.CommandBindings> </CheckBox> And the code behind: using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace Smt.Controls { public partial class SlideCheckBox : CheckBox { public SlideCheckBox() { InitializeComponent(); Loaded += OnLoaded; } public static readonly DependencyProperty CheckedTextProperty = DependencyProperty.Register("CheckedText", typeof(string), typeof(SlideCheckBox), new PropertyMetadata("Checked Text")); public string CheckedText { get { return (string)GetValue(CheckedTextProperty); } set { SetValue(CheckedTextProperty, value); } } public static readonly DependencyProperty UncheckedTextProperty = DependencyProperty.Register("UncheckedText", typeof(string), typeof(SlideCheckBox), new PropertyMetadata("Unchecked Text")); public string UncheckedText { get { return (string)GetValue(UncheckedTextProperty); } set { SetValue(UncheckedTextProperty, value); } } public static readonly RoutedCommand SlideCheckBoxClicked = new RoutedCommand(); void OnLoaded(object sender, RoutedEventArgs e) { Style style = TryFindResource("SlideCheckBoxStyle") as Style; if (!ReferenceEquals(style, null)) { Style = style; } } void OnSlideCheckBoxClicked(object sender, ExecutedRoutedEventArgs e) { IsChecked = !IsChecked; } } } The problem comes when I try to bind the "To" attribute in the DoubleAnimations to the actual width of the text, the same as I'm doing in the ControlTemplate. If I bind the values to an ActualWidth of an element in the ControlTemplate, the control comes up as a blank checkbox (my base class). However, I'm binding to the same ActualWidths in the ControlTemplate itself without any problems. Just seems to be the CheckBox.Resources that have a problem with it. For instance, the following will break it: <DoubleAnimation Storyboard.TargetName="CheckButton" Storyboard.TargetProperty="(Button.Width)" Duration="{StaticResource AnimationTime}" To="{Binding ElementName=CheckedText, Path=ActualWidth}" /> I don't know whether this is because it's trying to bind to a value that doesn't exist until a render pass is done, or if it's something else. Anyone have any experience with this sort of animation binding?

    Read the article

  • wpf treeview collapse/expand option disappeared

    - by Muhammad Adnan
    I used following code <!-- TreeView --> <Style x:Key="{x:Type TreeView}" TargetType="TreeView"> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="TreeView"> <Border Name="Border" CornerRadius="1" Background="{StaticResource WindowBackgroundBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1"> <ScrollViewer Focusable="False" CanContentScroll="False" Padding="4"> <ItemsPresenter/> </ScrollViewer> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- TreeViewItem --> <Style x:Key="TreeViewItemFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Border> <Rectangle Margin="0,0,0,0" StrokeThickness="5" Stroke="Black" StrokeDashArray="1 2" Opacity="0"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"> <Setter Property="Background" Value="Transparent"/> <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> <Setter Property="Padding" Value="1,0,0,0"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TreeViewItem}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <Border Name="Bd" Grid.Column="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"> <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/> </Border> <ItemsPresenter x:Name="ItemsHost" Visibility="Visible" Grid.Row="1" Grid.Column="0"/> </Grid> <ControlTemplate.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="HasHeader" Value="false"/> <Condition Property="Width" Value="Auto"/> </MultiTrigger.Conditions> <Setter TargetName="PART_Header" Property="MinWidth" Value="75"/> </MultiTrigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="HasHeader" Value="false"/> <Condition Property="Height" Value="Auto"/> </MultiTrigger.Conditions> <Setter TargetName="PART_Header" Property="MinHeight" Value="19"/> </MultiTrigger> <Trigger Property="IsSelected" Value="true"> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="true"/> <Condition Property="IsSelectionActive" Value="false"/> </MultiTrigger.Conditions> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> </MultiTrigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <TreeView> <TreeViewItem Header="Node 1"> <TreeViewItem Header="Node 1.1"> <TreeViewItem Header="Node 1.1.1" /> </TreeViewItem> </TreeViewItem> <TreeViewItem Header="Node 2"> <TreeViewItem Header="Node 2.1"> <TreeViewItem Header="Node 2.1.1" /> </TreeViewItem> <TreeViewItem Header="Node 2.2"> <TreeViewItem Header="Node 2.2.1" /> </TreeViewItem> </TreeViewItem> </TreeView> </Grid> taken from this url... http://stackoverflow.com/questions/1526925/can-i-have-a-treeview-without-the-tree-structure NOW I AM HAVING PROBLEM. I LOST COLLAPSE/EXPAND OPTIONS... HOW CAN I HAVE WITH THIS CODE...

    Read the article

  • WPF Button Image only showing in last control

    - by Ryan
    Hello All! I am fairly new to WPF and am probably missing something simple here. If I have 3 controls, only the last control will show the OriginalImage that I specify. Any help would be most appreciated. Thanks Ryan Main Window <Grid> <Grid.RowDefinitions> <RowDefinition Height="200*"/> <RowDefinition Height="60" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="85" /> <ColumnDefinition Width="85" /> <ColumnDefinition Width="85" /> <ColumnDefinition Width="85" /> <ColumnDefinition Width="300" /> </Grid.ColumnDefinitions> <Grid Grid.Row="1"> <but:ListButton OriginalImage="/CustomItemsPanel;component/ListBox/Images/add.png" DisableImage="/CustomItemsPanel;component/ListBox/Images/addunselect.png" /> </Grid > <Grid Grid.Row="1" Grid.Column="1" > <but:ListButton OriginalImage="/CustomItemsPanel;component/ListBox/Images/add.png" DisableImage="/CustomItemsPanel;component/ListBox/Images/addunselect.png" /> </Grid > <Grid Grid.Row="1" Grid.Column="2" > <but:ListButton OriginalImage="/CustomItemsPanel;component/ListBox/Images/add.png" DisableImage="/CustomItemsPanel;component/ListBox/Images/addunselect.png" /> </Grid> </Grid> Control XAML <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustomItemsPanel.ListButton"> <LinearGradientBrush x:Key="ButtonBackground" EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FF0E3D70"/> <GradientStop Color="#FF001832" Offset="1"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> <LinearGradientBrush x:Key="ButtonBackgroundMouseOver" EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.GradientStops> <GradientStop Color="#FF1E62A1" /> <GradientStop Color="#FF0A3C6D" Offset="1"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> <LinearGradientBrush x:Key="ButtonBackgroundSelected" EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.GradientStops> <GradientStop Color="Red" /> <GradientStop Color="#FF0A2A4C" Offset="1"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> <Style x:Key="Toggle" TargetType="{x:Type Button}"> <Setter Property="Content"> <Setter.Value> <Image> <Image.Style> <Style TargetType="{x:Type Image}"> <Setter Property="Source" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ListButton}}, Path=OriginalImage}"/> <Style.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Source" Value="{Binding Path=DisableImage, RelativeSource={RelativeSource TemplatedParent}}"/> </Trigger> </Style.Triggers> </Style> </Image.Style> </Image> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid Cursor="Hand"> <Border Name="back" Margin="0,1,0,0" Background="{StaticResource ButtonBackground}"> <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="content" /> </Border> <Border BorderThickness="1" BorderBrush="#FF004F92"> <Border BorderThickness="0,0,1,0" BorderBrush="#FF101D29" /> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True" > <Setter TargetName="back" Property="Background" Value="{StaticResource ButtonBackgroundMouseOver}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type local:ListButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:ListButton}"> <Button Style="{StaticResource Toggle}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> Control Code Behind public class ListButton : Control { public static readonly DependencyProperty MouseOverImageProperty; public static readonly DependencyProperty OriginalImageProperty; public static readonly DependencyProperty DisableImageProperty; static ListButton() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ListButton), new FrameworkPropertyMetadata(typeof(ListButton))); MouseOverImageProperty = DependencyProperty.Register("MouseOverImage", typeof(ImageSource), typeof(ListButton), new UIPropertyMetadata(null)); OriginalImageProperty = DependencyProperty.Register("OriginalImage", typeof(ImageSource), typeof(ListButton), new UIPropertyMetadata(null)); DisableImageProperty = DependencyProperty.Register("DisableImage", typeof(ImageSource), typeof(ListButton), new UIPropertyMetadata(null)); } public ImageSource MouseOverImage { get { return (ImageSource)GetValue(MouseOverImageProperty); } set { SetValue(MouseOverImageProperty, value); } } public ImageSource OriginalImage { get { return (ImageSource)GetValue(OriginalImageProperty); } set { SetValue(OriginalImageProperty, value); } } public ImageSource DisableImage { get { return (ImageSource)GetValue(DisableImageProperty); } set { SetValue(DisableImageProperty, value); } } }

    Read the article

  • Using MVVM, how to pass SelectedItems of a XamDataGrid as parameter to the Command raised by the Co

    - by saddaypally
    Hi, I'm trying to pass the item on XamDataGrid on which I do a mouse right click to open a ContextMenu, which raises a Command in my ViewModel. Somehow the method that the Command calls is not reachable in debug mode. This is the snipped from the view <ig:XamDataGrid DataSource="{Binding DrdResults}" Height="700" Width="600"> <ig:XamDataGrid.ContextMenu> <ContextMenu DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}" AllowDrop="True" Name="cmAudit"> <MenuItem Header="View History" Command="{Binding ViewTradeHistory}" CommandParameter="{Binding Path=SelectedItems}"> </MenuItem> </ContextMenu> </ig:XamDataGrid.ContextMenu> <ig:XamDataGrid.FieldSettings> <ig:FieldSettings AllowFixing="NearOrFar" AllowEdit="False" Width="auto" Height="auto" /> </ig:XamDataGrid.FieldSettings> </ig:XamDataGrid> My code in the corresponding ViewModel for this View is as follows public WPF.ICommand ViewTradeHistory { get { if (_viewTradeHistory == null) { _viewTradeHistory = new DelegateCommand( (object SelectedItems) = { this.OpenTradeHistory(SelectedItems); }); } return _viewTradeHistory; } } And lastly the actual method that gets called by the Command is as below private void OpenTradeHistory(object records) { DataPresenterBase.SelectedItemHolder auditRecords = (DataPresenterBase.SelectedItemHolder)records; // Do something with the auditRecords now. } I'm not sure what am I doing incorrectly here. Any help will be very much appreciated. Thanks, Shravan

    Read the article

  • Binding Image.Source to String in WPF ?

    - by Mohammad
    I have below XAML code : <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}" WindowStartupLocation="CenterScreen" Title="Window1" Height="300" Width="300"> <Grid> <Image x:Name="TestImage" Source="{Binding Path=ImageSource}" /> </Grid> </Window> Also, there is a method that makes an Image from a Base64 string : Image Base64StringToImage(string base64ImageString) { try { byte[] b; b = Convert.FromBase64String(base64ImageString); MemoryStream ms = new System.IO.MemoryStream(b); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); ////////////////////////////////////////////// //convert System.Drawing.Image to WPF image System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img); IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.ImageSource imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); Image wpfImage = new Image(); wpfImage.Source = imageSource; wpfImage.Width = wpfImage.Height = 16; ////////////////////////////////////////////// return wpfImage; } catch { Image img1 = new Image(); img1.Source = new BitmapImage(new Uri(@"/passwordManager;component/images/TreeView/empty-bookmark.png", UriKind.Relative)); img1.Width = img1.Height = 16; return img1; } } Now, I'm gonna bind TestImage to the output of Base64StringToImage method. I've used the following way : public string ImageSource { get; set; } ImageSource = Base64StringToImage("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABjUExURXK45////6fT8PX6/bTZ8onE643F7Pf7/pDH7PP5/dns+b7e9MPh9Xq86NHo947G7Hm76NTp+PL4/bHY8ojD67rc85bK7b3e9MTh9dLo97vd8/D3/Hy96Xe76Nfr+H+/6f///1bvXooAAAAhdFJOU///////////////////////////////////////////AJ/B0CEAAACHSURBVHjaXI/ZFoMgEEMzLCqg1q37Yv//KxvAlh7zMuQeyAS8d8I2z8PT/AMDShWQfCYJHL0FmlcXSQTGi7NNLSMwR2BQaXE1IfAguPFx5UQmeqwEHSfviz7w0BIMyU86khBDZ8DLfWHOGPJahe66MKe/fIupXKst1VXxW/VgT/3utz99BBgA4P0So6hyl+QAAAAASUVORK5CYIII").Source.ToString(); but nothing happen. How can I fix it ? BTW, I'm dead sure that the base64 string is correct

    Read the article

  • WPF Button Storyboard with an image for MouseOver

    - by Vinjamuri
    I have the following xaml for changing the image for WPF button when mouse is on the button. It give below error. Any help is appreciated... 'System.Windows.Media.Animation.DoubleAnimation' animation object cannot be used to animate property 'Source' because it is of incompatible type 'System.Windows.Media.ImageSource'. <Style TargetType="{x:Type local:ButtonControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:ButtonControl}"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Storyboard.TargetName="img" Storyboard.TargetProperty="Source" To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImage}" /> </Storyboard> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border> <Image x:Name="img" Source="pack://application:,,,/Recipe_06_13;component/Resources/normal.bmp" /> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • WPF Databound RadioButton ListBox

    - by Mark
    I am having problems getting a databound radiobutton listbox in WPF to respond to user input and reflect changes to the data it's bound to (i.e., to making changes in the code). The user input side works fine (i.e., I can select a radiobutton and the list behaves as expected). But every attempt to change the selection in code fails. Silently (i.e., no exception). Here's the relevant section of the XAML (I think): <Setter Property="ItemContainerStyle"> <Setter.Value> <Style TargetType="{x:Type ListBoxItem}" > <Setter Property="Margin" Value="2" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border Name="theBorder" Background="Transparent"> <RadioButton Focusable="False" IsHitTestVisible="False" IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" > <ContentPresenter /> </RadioButton> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Setter.Value> I bind the listbox to a List of SchoolInfo objects. SchoolInfo contains a property called IsSelected: public bool IsSelected { get { return isSelected; } set { if( value != isSelected ) { isSelected = value; this.OnPropertyChanged("IsSelected"); } } } The OnPropertyChanged() stuff was something I put in during my experimentation. It doesn't solve the problem. Things like the following fail: ((SchoolInfo) lbxSchool.Items[1]).IsSelected = true; lbxSchool.SelectedIndex = 1; They fail silently -- no exception is thrown, but the UI doesn't show the item being selected. Mark

    Read the article

  • TextBox, Button and ListBox in a ListBox

    - by Emil C
    I have a listbox with a bunch of contols in each list item. <ListBox x:Name="projectList" IsSynchronizedWithCurrentItem="True"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> <ListBox x:Name="taskList" ItemsSource="{Binding Tasks}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <TextBox x:Name="textBoxTask" /> <Button x:Name="ButtonAddNewTask" Content="Test" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}" Click="ButtonAddNewTask_Click" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> When I click on the button in the listbox i want to add a new item to the listbox within the listbox. I've come this far. So my question is how do I get hold of the textbox and how do I update the listbox? Here is my click event private void ButtonAddNewTask_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; Project proj = button.DataContext as Project; if(proj.Tasks == null) proj.Tasks = new List<Task>(); proj.Tasks.Add(new Task("Added Task")); } Thanx

    Read the article

  • Binding property to Silverlight dependency property independent of DataContext

    - by Simon_Weaver
    I'm trying to make an Address control that has an IsReadOnly property, which will make every TextBox inside read only when set to true. <my:AddressControl Grid.Column="1" Margin="5" IsReadOnly="True"/> I've managed to do this just fine with a dependency property and it works. Here's a simple class with the dependency property declared : public partial class AddressControl : UserControl { public AddressControl() { InitializeComponent(); this.DataContext = this; } public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(AddressControl), null); public bool IsReadOnly { get { return (bool)GetValue(IsReadOnlyProperty); } set { SetValue(IsReadOnlyProperty, value); } } } In the XAML for this codebehind file I have a Textbox for each address line: <TextBox IsReadOnly="{Binding IsReadOnly}" Text="{Binding City, Mode=TwoWay}"/> <TextBox IsReadOnly="{Binding IsReadOnly}" Text="{Binding State, Mode=TwoWay}"/> <TextBox IsReadOnly="{Binding IsReadOnly}" Text="{Binding Zip, Mode=TwoWay}"/> Like i said this works just fine. The problem is that the Address control itself is bound to its parent object (I have several addresses I am binding). <my:AddressControl DataContext="{Binding ShippingAddress, Mode=TwoWay}" IsReadOnly="True"> <my:AddressControl DataContext="{Binding BillingAddress, Mode=TwoWay}" IsReadOnly="True"> The problem is that as soon as I set DataContext to something other than 'this' then the binding for IsReadOnly breaks. Not surprising because its looking for IsReadOnly on the Address data entity and it doesn't exist or belong there. I've tried just about every combination of binding attributes to get IsReadOnly to bind to the AddressControl obejct but can't get it working. I've tried things like this, but I can't get IsReadOnly to bind independently to the AddressControl property instead of its DataContext. <TextBox IsReadOnly="{Binding RelativeSource={RelativeSource Self}, Path=IsReadOnlyProperty}" Text="{Binding City, Mode=TwoWay}" /> I think I'm pretty close. What am I doing wrong?

    Read the article

  • Databinding between UserControls?

    - by Dave
    I've got a situation where one of my UserControls would like to display a list of strings in a droplist, and the ItemsSource is set to another UserControl's ObservableCollection. The consumer of this data has its droplist defined in XAML like this: <ComboBox Grid.Column="1" SelectedItem="{Binding MyItem, Mode=TwoWay}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.MyItems}" Margin="3"></ComboBox> MyItems is defined as an ObservableCollection<string> in the producer UserControl. Now everything works fine when the controls are loaded. As long as MyItems is populated first, and then the consumer UserControl is displayed, all of the items are there. I obviously don't get any errors in the Output Window or anything like that. The issue I have is that when the ObservableCollection is modified, those changes are not reflected in the consumer UserControl! I've never had this problem before, but all of my previous uses of ObservableCollection with updating the collection are within a single control, and databinding is not inter-UserControl. Is there something I did wrong? Is there a good way to actually debug this? Reed Copsey indicates here that inter-UserControl databinding is possible. Unfortunately, my favorite Bea Stollnitz article on WPF databinding debugging doesn't suggest anything that I could use for this particular problem.

    Read the article

  • Binding WPF menu items to WPF Tab Control Items collection

    - by William
    I have a WPF Menu and a Tab control. I would like the list of menu items to be generated from the collection of TabItems on my tab control. I am binding my tab control to a collection to generate the TabItems. I have a TabItem style that uses a ContentPresenter to display the TabItem text in a TextBlock. When I bind the tab items to my menu the menu items are blank. I assume the menu items are looking for the Header property of the TabItems which I am not using. Is there a workaround for my scenario? Is it possible to bind to the Header property of the tab item, when I do not know the number of tabs in advance? Below is a copy of my xaml declarations. Tab Control and items: <DataTemplate x:Key="ClosableTabItemTemplate"> <DockPanel HorizontalAlignment="Stretch"> <Button Command="{Binding Path=CloseWorkSpaceCommand}" Content="X" Cursor="Hand" DockPanel.Dock="Right" Focusable="False" FontFamily="Courier" FontSize="9" FontWeight="Bold" Margin="10,1,0,0" Padding="0" VerticalContentAlignment="Bottom" Width="16" Height="16" Background="Red" /> <ContentPresenter HorizontalAlignment="Center" Content="{Binding Path=DisplayName}"> <ContentPresenter.Resources> <Style TargetType="{x:Type TextBlock}"/> </ContentPresenter.Resources> </ContentPresenter> </DockPanel> </DataTemplate> <DataTemplate x:Key="WorkspacesTemplate"> <TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" ItemTemplate="{StaticResource ClosableTabItemTemplate}" Margin="10" Background="#4C4C4C"/> </DataTemplate> My Menu <Menu Background="Transparent"> <MenuItem Style="{StaticResource TabMenuButtonStyle}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=Items}" ItemContainerStyle="{StaticResource TabMenuItem}"> </MenuItem> </Menu>

    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

  • WPF binding fails with custom add and remove accessors for INotifyPropertyChanged.PropertyChanged

    - by emddudley
    I have a scenario which is causing strange behavior with WPF data binding and INotifyPropertyChanged. I want a private member of the data binding source to handle the INotifyPropertyChanged.PropertyChanged event. I get some exceptions which haven't helped me debug, even when I have "Enable .NET Framework source stepping" checked in Visual Studio's options: A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll A first chance exception of type 'System.InvalidOperationException' occurred in PresentationCore.dll Here's the source code: XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="TestApplication.MainWindow" DataContext="{Binding RelativeSource={RelativeSource Self}}" Height="100" Width="100"> <StackPanel> <CheckBox IsChecked="{Binding Path=CheckboxIsChecked}" Content="A" /> <CheckBox IsChecked="{Binding Path=CheckboxIsChecked}" Content="B" /> </StackPanel> </Window> Normal implementation works public partial class MainWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public bool CheckboxIsChecked { get { return this.mCheckboxIsChecked; } set { this.mCheckboxIsChecked = value; PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs("CheckboxIsChecked")); } } private bool mCheckboxIsChecked = false; public MainWindow() { InitializeComponent(); } } Desired implementation doesn't work public partial class MainWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged { add { lock (this.mHandler) { this.mHandler.PropertyChanged += value; } } remove { lock (this.mHandler) { this.mHandler.PropertyChanged -= value; } } } public bool CheckboxIsChecked { get { return this.mHandler.CheckboxIsChecked; } set { this.mHandler.CheckboxIsChecked = value; } } private HandlesPropertyChangeEvents mHandler = new HandlesPropertyChangeEvents(); public MainWindow() { InitializeComponent(); } public class HandlesPropertyChangeEvents : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public bool CheckboxIsChecked { get { return this.mCheckboxIsChecked; } set { this.mCheckboxIsChecked = value; PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs("CheckboxIsChecked")); } } private bool mCheckboxIsChecked = false; } }

    Read the article

  • Conflict When Two Storyboards Sets the Opacity Property?

    - by kennethkryger
    Hi, Background: I have a WPF UserControl (MainControl - not shown in code below) that contains another one (called MyControl in the code below). MainControl has it's DataContext set to an object, that has a Project-property. When MainControl loads, the Project-property is always null. The problem: When MainControl loads, I want to fade in the MyControl using a special storyboard (only used this one time (this "specialFadeInStoryboard" changes Opacity-property of MyControl from 0 to 1). When the Project-property is set to a value other than null, I want the MyControl to fade out using the "fadeOutStoryboard" (changes Opacity-property of MyControl to 0) and if it's set to null afterwards I want to fade it in again this time using the "fadeInStoryboard" (changes Opacity-property of MyControl to 1). However, after adding the code for the "specialFadeInStoryboard", the MyControl is never faded out... What am I doing wrong? <local:MyControl Visibility="{Binding RelativeSource={RelativeSource Self}, Path=Opacity, Converter={StaticResource opacityToVisibilityConverter}, Mode=OneWay}"> <local:MyControl.Style> <Style> <Style.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded"> <BeginStoryboard Storyboard="{StaticResource specialFadeInStoryboard}"/> </EventTrigger> <DataTrigger Binding="{Binding Project, Converter={StaticResource nullToBooleanConverter}, Mode=OneWay}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource fadeOutStoryboard}"/> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard Storyboard="{StaticResource fadeInStoryboard}"/> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </local:MyControl.Style> </local:MyControl>

    Read the article

  • Listbox of comboboxes and binding them WPF

    - by Bashawy
    Hello, I have a situation where i have a listbox of comboboxes , mainly it binds to a bridge entity so the object contains foreign keys . What i need to do is that i need to bind the display of the combos to the respective entities and their value members to the foreign key values in the bridge entity that i bind the listbox to. the code i have now is : <ListBox Name="lstServices" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalContentAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Grid Margin="2" DataContext="{Binding ElementName=wndMain,Path=DataContext}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ComboBox Name="cmbService" SelectedIndex="0" DisplayMemberPath="Name" SelectedValuePath="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=FK_ServiceID}" ItemsSource="{Binding Path=AllServices}" Grid.Column="0"></ComboBox> <ComboBox Name="cmbService_Role" Margin="2,0,0,0" SelectedValuePath="{Binding Path=FK_ServiceRoleID}" DisplayMemberPath="Name" ItemsSource="{Binding Path=AllService_Roles}" Grid.Column="1"></ComboBox> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> I could manage to display the values that i needed but since the List Item context changed i can't get to the listbox itemSource . Any help is appreciated Bishoy

    Read the article

  • pass Validation error to UI element in WPF?

    - by Tony
    I am using IDataErrorInfo to validate my data in a form in WPF. I have the validation implemented in my presenter. The actual validation is happening, but the XAML that's supposed to update the UI and set the style isn't happening. Here it is: <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/> <Setter Property="Background" Value="Red"/> </Trigger> </Style.Triggers> </Style> The problem is that my binding to Validation.Errors contains no data. How do I get this data from the Presenter class and pass it to this XAML so as to update the UI elements? EDIT: Textbox: <TextBox Style="{StaticResource textBoxInError}" Name="txtAge" Height="23" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Width="150"> <TextBox.Text> <Binding Path="StrAge" Mode="TwoWay" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged"/> </TextBox.Text> The validation occurs, but the style to be applied when data is invalid is not happening.

    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: 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

  • 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

< Previous Page | 1 2 3 4 5 6 7  | Next Page >