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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:48:30+00:00 2026-05-23T14:48:30+00:00

I have a main window with following code: <Window x:Class=CAMXSimulator.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:View=clr-namespace:CAMXSimulator.View xmlns:ViewModel=clr-namespace:CAMXSimulator.ViewModel

  • 0

I have a main window with following code:

<Window x:Class="CAMXSimulator.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:View="clr-namespace:CAMXSimulator.View"
        xmlns:ViewModel="clr-namespace:CAMXSimulator.ViewModel"
        Icon="Resources/Images/Tractor.png"
        Title="{Binding WindowTitle}"

        Height="400" Width="600">

    <Window.Resources>
        <DataTemplate DataType="{x:Type ViewModel:LogParserViewModel}">
            <View:LogView />
        </DataTemplate>
    </Window.Resources>

        <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
             <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
         </Grid.RowDefinitions>



        <Border CornerRadius="5" BorderBrush="SteelBlue" BorderThickness="2" Grid.Row="2" Margin="0,5,5,0" >
            <View:LogView  />
        </Border>

    </Grid>

</Window>

in the LogParserViewModel.cs class i have the following

EDIT:

class LogParserViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
      //  public event PropertyChangedEventHandler PropertyChanged1;
        private IDbOperations _camxdb;
        #region private_virables
        private string _vManageLogFile;
        private string _camxNodes;
        private IEnumerable<Tuple<string, string>> _camxnodesAsTuple;
        RelayCommand _clearFieldscommand;
        RelayCommand _runsimulationcommand;

        private string _currentProfileName;

        #endregion

        #region Getters\Setters
        public string CurrentProfileName
        {
            get { return _currentProfileName; }
            set
            {
                _currentProfileName = value;
                OnPropertyChanged("CurrentProfileName");
                OnPropertyChanged("WindowTitle");
            }
        }



        public string VManageLogFile
        {
            get { return _vManageLogFile; }
            set { _vManageLogFile = value;

                    if(null != PropertyChanged)
                    {
                      //  PropertyChanged(this, new PropertyChangedEventArgs("VManageLogFile"));
                        OnPropertyChanged("VManageLogFile");
                    }
            }
        }

        public string CamxNodes
        {
            get { return _camxNodes; }
            set
            {
                _camxNodes = value;
                if (null != PropertyChanged)
                {
                    //PropertyChanged1(this, new PropertyChangedEventArgs("CamxNodes"));
                    OnPropertyChanged("CamxNodes");
                }

            }
        }
        #endregion

        protected void OnPropertyChanged(string name)
        {
           // PropertyChangedEventHandler handler = PropertyChanged;
            if (PropertyChanged != null )
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }

        #region Constructors
        public LogParserViewModel()
        {
           // PropertyChanged1 = new PropertyChangedEventHandler();
            //PropertyChanged += UpdateCamxWindowEvent;
            PropertyChanged += (s, e) => { if (e.PropertyName == "VManageLogFile") UpdateCamxWindowEvent(s, e); };

            //creates a instance of database object
            _camxdb = new DbOperations();


        }
        #endregion

        #region Event_Hendlers
        /// <summary>
        /// This event is called when vManageLog window has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateCamxWindowEvent(object sender, EventArgs e)
        {
            if (_vManageLogFile == null)
                return;

            //creates object of parser 
            var parser = new VManageLogParser(_vManageLogFile);
            //returns a tuple of string string 
            _camxnodesAsTuple = parser.Parse();
            //creates a string as we see it in the CAMX window of the simulator
            CamxNodes = parser.CamxWindowText2(_camxnodesAsTuple);
            MyLogger.Logger.Info("The Tabs been updated");

            CurrentProfileName = "CAMX Simulator";


        }
        #endregion

        #region Drag & DragOver
        public  void DragOver(DragEventArgs args)
        {
            // As an arbitrary design decision, we only want to deal with a single file.
            if (IsSingleTextFile(args) != null) args.Effects = DragDropEffects.Copy;
            else args.Effects = DragDropEffects.None;

            // Mark the event as handled, so TextBox's native DragOver handler is not called.
            args.Handled = true;
        }

        public void Drop(DragEventArgs args)
        {
            using (new WaitCursor())
            {


                // Mark the event as handled, so TextBox's native Drop handler is not called.
                args.Handled = true;

                string fileName = IsSingleTextFile(args);
                if (fileName == null) return;

                StreamReader fileToLoad = new StreamReader(fileName);
                VManageLogFile = fileToLoad.ReadToEnd();
                // DisplaySFMFileContents.Text = fileToLoad.ReadToEnd();

                fileToLoad.Close();

            }
        }

        // If the data object in args is a single file, this method will return the filename.
        // Otherwise, it returns null.
        private  string IsSingleTextFile(DragEventArgs args)
        {
            // Check for files in the hovering data object.
            if (args.Data.GetDataPresent(DataFormats.FileDrop, true))
            {
                string[] fileNames = args.Data.GetData(DataFormats.FileDrop, true) as string[];
                // Check fo a single file or folder.
                if (fileNames.Length == 1)
                {
                    // Check for a file (a directory will return false).
                    if (File.Exists(fileNames[0]))
                    {
                        //Check for the file extention , we look only for txt extentions
                        FileInfo info = new FileInfo(fileNames[0]);
                        if (info.Extension == ".txt")
                        {
                            MyLogger.Logger.Info("Name of file: " + fileNames[0]);
                            // At this point we know there is a single file text file.);
                            return fileNames[0];
                        }

                    }
                }
            }
            MyLogger.Logger.Warn("Not a single file");
            return null;
        }
        #endregion

        #region ClearCommand

        public ICommand ClearFieldsCommand
        {
            get
            {
                if (_clearFieldscommand == null)
                    _clearFieldscommand = new RelayCommand(
                        () => ClearFields(),
                        () => CanClearWindows);

                return _clearFieldscommand;
            }
        }

        void ClearFields()
        {
            VManageLogFile = null;
            CamxNodes = null;
        }
        bool CanClearWindows
        {
            get { return (VManageLogFile != null ); }
        }


        #endregion

        #region RunSimulation
        public ICommand RunSimulationCommand
        {
            get
            {
                if (_runsimulationcommand == null)
                    _runsimulationcommand = new RelayCommand(
                        () => RunSimulation(),
                        () => CanRunSimulation);

                return _runsimulationcommand;
            }
        }

        void RunSimulation()
        {
            using (new WaitCursor())
            {
                try
                {   //inserting the CAMX nodes to the table
                    foreach (var camxNode in _camxnodesAsTuple)
                    {
                        _camxdb.Insert(camxNode);

                    }
                }
                catch (Exception ex )
                {

                    MyLogger.Logger.FatalException("Cannot Insert to Database" , ex);
                }

            }
        }

        bool CanRunSimulation
        {
            get { return !GlobalMethods.IsEmpty(_camxnodesAsTuple); }
        }
        #endregion
    }
}

And I am trying to change the windows title by seeting it but nothing is happens any idea why ?

  • 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-23T14:48:30+00:00Added an answer on May 23, 2026 at 2:48 pm

    As I can’t see from the current code what the DataContext of the main.xaml is, I’m going to take a guess that it is itself (not set to something else). I’m going to further go and say that your intent is to set the main.xaml’s DataContext to a ViewModel:

    XAML:

    <Window x:Class="Namespace.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding WindowTitle}">
    
        <!-- YOUR XAML -->
    
    </Window>
    

    Code Behind:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MainWindowViewModel();
        }
    }
    

    Where MainWindowViewModel.cs contains the property for the WindowTitle.

    If you want a some other class to control the WindowTitle then you’ll still need to have a ViewModel for your MainWindow (i.e. MainWindowViewModel.cs) that accepts messages somehow (events for tightly coupled, event aggregation for loosely coupled) to update that property.

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

Sidebar

Related Questions

I am making a custom titlebar using the following xml file: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/myTitle
I have following class as the main window: public partial class Window1 : Window
I have the very simple following code: main.cpp #include ui_library_browser.h #include <QtGui/QApplication> #include StartWindow.h
I have a main window class built in Qt Designer and called Ui_MainWindow which
I have written the following code to set the cursor of a Gtk::Window from
I have the following code. Class KochSnowflakesMenu is a grid JPanel with three buttons.
Say I have the following code: import java.lang.InterruptedException; import javax.swing.SwingWorker; public class Test {
I have the following files (Main window/UI): files UI: # -*- coding: utf-8 -*-
I have a C# windows application which does the following: 1) the main form
I have a main window (#1) on my webpage from which I open a

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.