Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:19:11+00:00 2026-06-17T13:19:11+00:00

The application ia a messenger in which I am using microsoft lync client for

  • 0

The application ia a messenger in which I am using microsoft lync client for this purpose. In one of the context I am getting the contacts (which is an object of LyncClient having properties like name, image , Availability, etc) in a listview and loading them in a data template which is defined as follow:

<DataTemplate x:Key="ContactsTemplate">
        <Grid HorizontalAlignment="Left" Width="150" Height="150" Margin="10">
            <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
                <Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
            </Border>
            <StackPanel VerticalAlignment="Bottom" Background="{Binding Availability, Converter={StaticResource AvailabilityToPresenceColor}}" Opacity="0.75">
                <TextBlock Text="{Binding Name}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="20" Margin="15,0,15,15"/>
            </StackPanel>
        </Grid>
    </DataTemplate>

It has Grid container in which we have an image and textblock controls which show the image and name of the contact and as its shown below the background of stackpanel is binded to Availability property of lync Contact object with a converter which map the availibility status to a color so that for example the background of stackpanel will turn red when the contact availibility is busy.

I want to have similar effect for the image control as well.

I am new to binding so totaly lost in this bindig concept.

My idea was: there is a effect evend handler for image so i thought of using that for this purpose and use

and inside the converter under some condition I want to use some code in which i need to get the image source, but as we are getting the image source through binding

please suggest me your ideas.


Well as u can see in the code
<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title} effect="{Binding Availability, Converter={StaticResource AvailabilityToPresenceColor}}"/>
I am just binding source of image control with a property of Contact object. I want to send the Availability properties of a Contact object to Convert method of IValueConverter or I want to bind the image with the whole Contact Object if it is possible…or if some other way please let me know.

#####################comment attachment

var bitmap = new BitmapImage();
    bitmap.BeginInit();
    MemoreyStream ms=new MemoryStream(_image);
    bitmap.StreamSource = stream;
    bitmap.CacheOption = BitmapCacheOption.OnLoad;
    bitmap.EndInit();
 var grayBitmapSource = new FormatConvertedBitmap();
    grayBitmapSource.BeginInit();
    grayBitmapSource.Source = ms;
    grayBitmapSource.DestinationFormat = PixelFormats.Gray32Float;
    grayBitmapSource.EndInit();
.....

now the thing is i have grayBitmapSource which is of type FormatConvertedBitmap and i dont know how to convert it to Stream again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:19:13+00:00Added an answer on June 17, 2026 at 1:19 pm

    I would suggest looking at this article about image processing in WPF: http://www.codeproject.com/Articles/237226/Image-Processing-is-done-using-WPF

    Using the image processing logic, you create the different pictures for each availability status. You could use an IValueConverter, but that means you have to reprocess the image each time the availability status changes. Instead, you can simply change your Contact class so that when you change the Availability property, it automatically signals WPF to get the picture referenced by the Image property:

    public class Contact : INotifyPropertyChanged
    {
        // EDIT: INotifyPropertyChanged implementation.
        public event PropertyChangedEventHandler PropertyChanged;
    
        public void NotifyPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        // EDIT: INotifyPropertyChanged implementation.
    
        private ContactAvailability _Availability;
    
        public ContactAvailability Availability
        {
            get { return _Availability; }
            set
            {
                _Availability = value;
                NotifyPropertyChanged("Availability");
                NotifyPropertyChanged("Image");
            }
        }
    
        public BitmapImage _AvailablePicture;
        public BitmapImage _BusyPicture;
    
        public BitmapImage Image
        {
            get
            {
                switch (this.Availability)
                {
                    case ContactAvailability.Available:
                        return this._AvailablePicture;
                    case ContactAvailability.Busy:
                        return this._BusyPicture;
                    default:
                        throw new NotImplementedException();
                }
            }
        }
    }
    

    EDIT (too long for comment):

    I added the code to implement the INotifyPropertyChanged interface. This is very common in WPF so I thought you were familiar with this approach already.

    In your example, Image.Source is a DepencyProperty. When a class implements INotifyPropertyChanged, you can tell WPF that one of its properties has changed. You simply raise the NotifyPropertyChanged event with the name of the property that changed. This signals WPF to update all DepencyPropertys that bind to the given property.

    how is this different with binding in term of image processing. I mean every time the availibility changes then in this way also the image processing code should be execute as well. am I right or not @bouvierr?

    No. In this case, we would only execute the image processing a fixed number of times to create the picture for each availability status (2 times for each contact in my example). For example, we could create all pictures during application startup (3 contact x 2 status = 6 pictures) and store them in each contact’s _AvailablePicture and _BusyPicture fields.

    Here is the IMPORTANT part: when we SET the Availability property, we also call NotifyPropertyChanged("Image"). This will force WPF to update the Image.Source DepencyProperty because it binds to Contact.Image. This will return a different picture, because the Availability has changed.

    In my example, I decided to store the pictures. This might not be the best solution for you. It consumes more memory, but saves processing time. If you prefer to re-process images each time the Availability status changes, you should change the Contact.Image property to something like:

        public BitmapImage Image
        {
            get
            {
                switch (this.Availability)
                {
                    case ContactAvailability.Available:
                        return this._AvailablePicture;
                    case ContactAvailability.Busy:
                        return GetImageWithColorFilter(this._AvailablePicture, Colors.Red);
                    default:
                        throw new NotImplementedException();
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My messenger Application is using more than 100% CPU usage.How can one program use
I'm using an application (an instant messenger) which is not very popular. I'm trying
My application has one activity which starts two services but does not bind them.
I am writing application which intented to replace standard/stock messenger. So I need to
I have a client-server application that works kinda like a messenger, the application is
I am trying to create a ZF application that also includes Mibew Messenger which
a customer wants enable a chat/instant messenger for his application webside. He is using
ok I have this application which needs to send periodic updates to a web-service,
I'm getting this error intermittently on my MVC 2 web application. My models do
iv'e got an mvvm application , in a viewmodel : public CommandViewModel() { Messenger.Default.Register<CustomerSavedMessage>(this,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.