1

How to code a converter in WPF to display four status icons in WPF, In my project I am planning to display following four status based on certain conditions 1) Red Dot icon - Unsaved data 2) Green Dot icon - Save successful 3) White Dot icon OR No icon - window has Initialized successfully and there is no unsaved data. 4) Error icon - There were errors while saving data.

Any help would be highly appreciated, thanks in advance.

1
  • you mean how to change the icon showed in the window title or just to display dots? Commented Sep 1, 2009 at 11:49

1 Answer 1

1

If you want to change the window icon the simpliest way is to create all icons and save them as resource and then change it with:

Uri iconUri = new Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);

If you want just to display dots on your form you draw a circle and change its color with yourCircle.Fill(newColor)

This example is from msdn:

To draw a circle, specify an Ellipse whose Width and Height values are equal.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SDKSample
{
    public partial class SetBackgroundColorOfShapeExample : Page
    {
        public SetBackgroundColorOfShapeExample()
        {
            // Create a StackPanel to contain the shape.
            StackPanel myStackPanel = new StackPanel();
            // Create a red Ellipse.
            Ellipse myEllipse = new Ellipse();
            // Create a SolidColorBrush with a red color to fill the 
            // Ellipse with.
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();
            // Describes the brush's color using RGB values. 
            // Each value has a range of 0-255.
            mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
            myEllipse.Fill = mySolidColorBrush;
            myEllipse.StrokeThickness = 2;
            myEllipse.Stroke = Brushes.Black;
            // Set the width and height of the Ellipse.
            myEllipse.Width = 200;
            myEllipse.Height = 100;
            // Add the Ellipse to the StackPanel.
            myStackPanel.Children.Add(myEllipse);
            this.Content = myStackPanel;
        }
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, As Suggested I will draw circle and change its color.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.