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

  • Home
  • SEARCH
  • 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 9259023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:20+00:00 2026-06-18T12:33:20+00:00

I’m not sure if the array is really the issue here but I have

  • 0

I’m not sure if the array is really the issue here but I have a rectangle which I want to move from one side of the window to the other when the MouseUp event is raised. I have this rectangle bound to an array element and the MouseUp event handler method changes the value of that array. I know the handler method works as it can pull up a message box fine, just not switch the position of the rectangle.

Note: The array is necessary, this is just code for testing these concepts, not my actual project.

Also the simplest method to solve this issue would be greatly appreciated.

C# Code:

namespace WPFTestingApplication
{
    public static class GridProperties
    {
        public static int[] gridColumn = { 0 };
    }

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Rect_MouseUp_1(object sender, MouseButtonEventArgs e)
        {
            GridProperties.gridColumn[0] = 1;
        }
    }
}

XAML Code:

<Window x:Class="WPFTestingApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WPFTestingApplication"
        Title="MainWindow" Height="200" Width="400">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Rectangle Name="Rect" Grid.Column="{Binding [0], Source={x:Static local:GridProperties.gridColumn}, Mode=OneWay}" Fill="DarkGray" Margin="5" MouseUp="Rect_MouseUp_1"/>
    </Grid>
</Window>
  • 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-18T12:33:22+00:00Added an answer on June 18, 2026 at 12:33 pm

    The array is the problem. You should read up on INotifyPropertyChanged, nothing you bind to will be updated without it.

    If you can, change your array to an ObservableCollection which implements INotifyPropertyChanged for changes to its elements. You can index it just like it’s an array.

    You may also have issues with storing the property collection in a static class. Static classes and properties don’t have property changed notifications. If it’s possible for the GridProperties to be a property on the window class that will be easier. Then, set the DataContext of the window to itself.

    Something like this works for your example. Can’t tell if you have something more complicated in your actual project though.

    C#:

    public partial class MainWindow : Window
    {
        public ObservableCollection<int> GridProperties { get; private set; }
    
        public MainWindow()
        {
            InitializeComponent();
            GridProperties = new ObservableCollection<int>();
            GridProperties.Add(0);
            DataContext = this;
        }
    
        private void Rect_MouseUp_1(object sender, MouseButtonEventArgs e)
        {
            GridProperties[0] = 1;
        }
    }
    

    xaml:

    <Grid>
        <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Rectangle Name="Rect" Grid.Column="{Binding GridProperties[0]}" Fill="DarkGray" Margin="5" MouseUp="Rect_MouseUp_1"/>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I want to count how many characters a certain string has in PHP, but
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have a view passing on information from a database: def serve_article(request, id): served_article

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.