Dear All,
i am having requirement to show based upon data some list items should be highlighted (Blinking effect) and some should show colors only
bellow is the data set. data set contains NAME, BackgroundColor and triggerrequired items.
list view Item template is created with Ellipse, and Textblock.
Ellipse fill is binded to the BackgroundColor property. therefore list view is showing in correct manner. some items with green color and some items showing in red as for the business requirements.
in addition to the above now we want to create Blink effect (storyboard) for the red colored list item.
it is giving fallowing error message: Initialization of 'System.Windows.Shapes.Ellipse' threw an exception.
public string name { get; set; } public string ID { get; set; } public Brush BackgroundColor { get; set; } public string Status { get; set; } private string _triggerrequired; public string triggerRequired { get { return _triggerrequired; } set { _triggerrequired = value; OnPropertyChanged("triggerRequired"); } } public void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
<DataTemplate x:Key="DataTemplate1"><Grid Width="200" Height ="40"><Grid.ColumnDefinitions><ColumnDefinition Width="50"/><ColumnDefinition/></Grid.ColumnDefinitions><Ellipse x:Name="ellipse" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="3.25,3.6,0,0" Stroke="Black" Width="40" Fill="{Binding BackgroundColor}" ><Ellipse.Triggers><DataTrigger Binding="{Binding triggerRequired}" Value="YES" ><DataTrigger.EnterActions><BeginStoryboard><Storyboard><ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" Duration="0:0:2" FillBehavior="HoldEnd" RepeatBehavior="Forever"><ColorAnimationUsingKeyFrames.KeyFrames><DiscreteColorKeyFrame KeyTime="0:0:0" Value="Red"/><DiscreteColorKeyFrame KeyTime="0:0:1" Value="Blue"/></ColorAnimationUsingKeyFrames.KeyFrames></ColorAnimationUsingKeyFrames></Storyboard></BeginStoryboard></DataTrigger.EnterActions></DataTrigger></Ellipse.Triggers></Ellipse><TextBlock TextWrapping="Wrap" Text="{Binding name}" Grid.Column="1" FontWeight="Bold" Foreground="Black" Margin="3.2,0,0,0" TextAlignment="Left" VerticalAlignment="Center" /></Grid></DataTemplate>