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 3283446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:02:34+00:00 2026-05-17T20:02:34+00:00

I have a View which has a list of items bound to my ViewModel

  • 0

I have a View which has a list of items bound to my ViewModel (MVVM pattern).

Let’s say it looks like that:

<ScrollViewer Width="Auto" Height="Auto">
    <ItemsControl ItemsSource="{Binding Path=MessageLog}" 
                  Grid.IsSharedSizeScope="True"                     
                  ScrollViewer.CanContentScroll="True">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150" SharedSizeGroup="FullName"/>
                        <ColumnDefinition Width="*" SharedSizeGroup="MessageLog"/>
                    </Grid.ColumnDefinitions>                                   
                    <StackPanel>
                        <TextBlock Text="{Binding Path=PostedBy.FullName}" />
                        <TextBlock Text="{Binding Path=DatePosted}" />
                    </StackPanel>
                    <TextBlock Grid.Column="1" Text="{Binding Path=MessageLog}"/>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>

When user adds something to MessageLog (there is a property MessageLog in VM) I want to automatically scroll to the most recent item.

In other words, I just want to move the scrollbar automatically when user type a message and hit the enter (something like Skype does).

Binding on MessageLog works as expected and item is updated on the view. (I’m happy about that and I want to leave it like that)

I am wondering if using MVVM pattern approach, can I still implement an auto scroll in code behind file of the View? It seems to be quite logic as scrolling behavior has nothing to do with the VM and ViewModel doesn’t know anything about the View. Is it right? Am I going right way or I am missing something?

Generally speaking, when adding an implementation to a View makes sense?

  • 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-05-17T20:02:34+00:00Added an answer on May 17, 2026 at 8:02 pm

    Yes, this is perfectly acceptable. Since the logic here is 100% View related, there is no problem with adding it to the View.

    MVVM is about separating your Application logic from your View logic, not necessarily about stripping 100% of the code out of your View.

    That being said, there are alternatives to code behind for this. Attached properties (or Behaviors) are a great option for tasks like these – they have the large advantage of being reusable in other Views later, so you don’t reinvent this later if you decide you want the same behavior in other parts of your User Interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has a list of items (which can be added
I have a list view item which has a button and displays properties on
I have a basic iPhone/iPad app which has a ; a. List view &
I have a DatePicker working on a View which also has a ViewModel associated
I have a silverlight control (View) which displays a list of items in a
I have a list view which has been registered for a context menu. For
I have a drop down list on a form view which are both bound
I have a view which has two labels. When I swipe left I fill
I have a custom view which has a piano keyboard drawn inside of it.
I have a tab view which has a listview in one of these tabs.

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.