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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:07:57+00:00 2026-06-07T11:07:57+00:00

My ICommand will not trigger unless I move the DataContext field into the the

  • 0

My ICommand will not trigger unless I move the DataContext field into the the DataTemplate (contlisttemplate) for the Button. I have images set in a style resource, those disappear as soon as I move the DataContext field into the DataTemplate. Both images and ICommand should be using the same DataContext so I am unsure of why it will not work.

Here is a snippet of my code below.

DataContext="{Binding LongListViewModel, Source={StaticResource viewModelLocator}}"

<i:Interaction.Behaviors>
    <GamePad:XboxBehavior StartFocusControlName="continuousList1" IsTopLevelViewForFocus="True"/>
</i:Interaction.Behaviors>

<UserControl.Resources>
    <DataTemplate x:Key="contlisttemplate" >
        <Button  
            Command="{Binding Gotodetailpage}"
            Style="{StaticResource custherotile}">
        </Button> 
    </DataTemplate>
</UserControl.Resources>

<Grid x:Name="LayoutRoot">
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <xbox:ContinuousList 
        HorizontalAlignment="Left" 
        Name="continuousList1" 
        VerticalAlignment="Top"                      
        ItemTemplate="{StaticResource contlisttemplate}"
        ItemsSource="{Binding LongListItems}" Height="316" Width="1280"
        Grid.Row="1"
        >

        <i:Interaction.Behaviors>
            <GamePad:XboxBehavior IsContinuousListVuiEnabled="True" HasFocusRetention="True"/>
        </i:Interaction.Behaviors>

    </xbox:ContinuousList>

public class LongListViewModel : ViewModelBase<LongListViewModel>
{
    private readonly IDialogService dialogService;
    public Navigateto compass = new Navigateto();

    public LongListViewModel()
    {
        LongListItems = new ObservableCollection<object>();
        dictionaryListwithkey = new Dictionary<string, object>();
        Gotodetailpage = new RelayCommand(PerformGotoDetailPage);
    }

    public LongListViewModel(IDialogService dialogService)
        : this()
    {
        this.dialogService = dialogService;
    }


    public Program getherovideo
    {
        get { return (Program)LongListItems[0]; }
        set
        {
            //SetProperty(ref currentVideo, value,x => x.CurrentVideo);
        }
    }

    public ObservableCollection<object> LongListItems
    {
        get;
        set;
    }


    public Dictionary<string, object> dictionaryListwithkey
    {
        get;
        set;
    }

    public ICommand Gotodetailpage { get; private set; }

    private void PerformGotoDetailPage()
    {
       // Console.WriteLine("List item clicked");
        compass.goToDetailsPageWithPath("89");
    }
}
  • 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-07T11:07:59+00:00Added an answer on June 7, 2026 at 11:07 am

    In case anyone was wondering what the answer was . As per Aaron Hill ATG :

    This looks like an issue of scope. The outer DataContext is your LongListViewModel class, which contains the desired ICommand, but the ItemsSource for the container is set to the LongListItems collection exposed by the view-model. This means the effective DataContext for the DataTemplate is an individual member of the collection, not the overall view-model.

    Overriding the DataContext of the DataTemplate would let you point back to the view-model and access the ICommand, however it also means you lose any data present within the individual elements of the LongListItems collection. That is probably why the images no longer work in this case.

    Since each item in the collection has its own button, it probably makes sense for the ICommand property to be exposed on the individual item rather than the view-model.

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

Sidebar

Related Questions

Say you have a button whose command property is bound to some ICommand of
I have a button bound to a ICommand <Button Content=Remove Command={Binding RemoveCommand} x:Name=btnRemove Visibility=Collapsed
What is the simplest way to bind an ICommand to a DataGridTextColumn that will
I am try to Binding a ICommand property on a Button Command from MainWindow.
I have got a StartCommand Class: public class StartCommand : ICommand { public void
I've a simple question about commands in WPF : I have a button with
I've got a button strip usercontrol that I want to have on most of
I have an ICommand that I want to fire (make the execute go) from
I have the below method: public void Enqueue(ICommand itemToQueue) { if (itemToQueue == null)
I have the following class hierarchy [BsonKnownTypes(typeof(MoveCommand))] public abstract class Command : ICommand {

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.