View Issue Details

IDProjectCategoryView StatusLast Update
0003859NoesisGUIVSCodepublic2026-10-16 12:07
ReporterMarioBarbero Assigned Tomaherne  
PrioritynormalSeverityfeature 
Status assignedResolutionopen 
Product Version3.2.6 
Target Version4.0.3 
Summary0003859: IntelliCode in XAML with DataContext defined in xaml file
Description

I am using VisualStudio Code with NoesisGUI XAML extension. I have set DataContext in design time to make auto-suggestions
the properties that I have created in View Model but it doesn´t suggest anything when I make the bindings.

Steps To Reproduce

Set Datacontext in XAML file instead cs file. Then, try type one property that you have in ViewModel.
Right now, it does not suggest the properties that you have defined in the ViewModel.

Attached Files
MainWindow.xaml (1,220 bytes)   
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"          
        xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
        xmlns:local="clr-namespace:Test"
        xmlns:controls="clr-namespace:Test.Controls"
        mc:Ignorable="d"
        Title="MainWindow" Height="850" Width="1200" Background="AliceBlue"
        x:Name="vMain">

    <Window.DataContext>
        <local:MainWindowViewModel />
    </Window.DataContext>

    <StackPanel Orientation="Vertical">
        <ComboBox ItemsSource="{Binding Source}"/>

        <Button Width="100" Height="25" Content="Add combobox" Command="{Binding AddComboCommand}" CommandParameter="{Binding ElementName=ComboBoxContainer}">

        </Button>

        <WrapPanel x:Name="ComboBoxContainer" Orientation="Horizontal" >
            
        </WrapPanel>
    </StackPanel>   
</Window>
MainWindow.xaml (1,220 bytes)   
MainWindow.xaml.cs (663 bytes)   
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Test.Util;

namespace Test
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //myGrid.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight / 50;
        }
    }
}
MainWindow.xaml.cs (663 bytes)   
MainWindowViewModel.cs (1,435 bytes)   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Test.Util;

namespace Test
{
    public class MainWindowViewModel
    {
        public ImageSource ImageSource { get; set; }
        public string StringPath { get; set; }
        public List<string> Source { get; set; } = new List<string>() { "Hola", "Adios", "Hasta luego", "Qué tal" };

        public ICommand AddComboCommand { get; set; }

        public MainWindowViewModel()
        {
            StringPath = "pack://application:,,,/Resources/Miguel-Indurain-2.webp"; // Ruta relativa
            ImageSource = new BitmapImage(new Uri(StringPath));

            AddComboCommand = new RelayCommand<WrapPanel>(AddCombo, null);
        }

        private void AddCombo(WrapPanel o)
        {
            ComboBox newComboBox = new ComboBox
            {
                Width = 100,
                Margin = new Thickness(0, 0, 10, 0)
            };

            List<string> items = new List<string> { "Pepito", "Manolito", "Luisito" };
            foreach (var item in items)
            {
                newComboBox.Items.Add(item);
            }

            o.Children.Add(newComboBox);
        }
    }
}
MainWindowViewModel.cs (1,435 bytes)   
PlatformWindows

Activities

MarioBarbero

MarioBarbero

2024-12-13 14:51

reporter   ~0010224

RelayCommand.cs (2,765 bytes)   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Test.Util
{
    public class RelayCommand<T> : ICommand
    {
        #region Fields

        readonly Action<T> _execute = null;
        readonly Predicate<T> _canExecute = null;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of <see cref="DelegateCommand{T}"/>.
        /// </summary>
        /// <param name="execute">Delegate to execute when Execute is called on the command.  This can be null to just hook up a CanExecute delegate.</param>
        /// <remarks><seealso cref="CanExecute"/> will always return true.</remarks>
        public RelayCommand(Action<T> execute)
            : this(execute, null)
        {
        }

        /// <summary>
        /// Creates a new command.
        /// </summary>
        /// <param name="execute">The execution logic.</param>
        /// <param name="canExecute">The execution status logic.</param>
        public RelayCommand(Action<T> execute, Predicate<T> canExecute)
        {
            if (execute == null)
                throw new ArgumentNullException("execute");

            _execute = execute;
            _canExecute = canExecute;
        }

        #endregion

        #region ICommand Members

        ///<summary>
        ///Defines the method that determines whether the command can execute in its current state.
        ///</summary>
        ///<param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        ///<returns>
        ///true if this command can be executed; otherwise, false.
        ///</returns>
        public bool CanExecute(object parameter)
        {
            return _canExecute == null ? true : _canExecute((T)parameter);
        }

        ///<summary>
        ///Occurs when changes occur that affect whether or not the command should execute.
        ///</summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        ///<summary>
        ///Defines the method to be called when the command is invoked.
        ///</summary>
        ///<param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
        public void Execute(object parameter)
        {
            _execute((T)parameter);
        }

        #endregion
    }
}
RelayCommand.cs (2,765 bytes)   

Issue History

Date Modified Username Field Change
2024-12-13 14:22 MarioBarbero New Issue
2024-12-13 14:22 MarioBarbero Tag Attached: WPF
2024-12-13 14:22 MarioBarbero Tag Attached: xaml;DataContext;IntelliCode;VisualStudio Code;NoesisGUI XAML;
2024-12-13 14:22 MarioBarbero File Added: MainWindow.xaml
2024-12-13 14:22 MarioBarbero File Added: MainWindow.xaml.cs
2024-12-13 14:22 MarioBarbero File Added: MainWindowViewModel.cs
2024-12-13 14:40 MarioBarbero Tag Attached: xaml
2024-12-13 14:40 MarioBarbero Tag Attached: DataContext
2024-12-13 14:40 MarioBarbero Tag Attached: IntelliCode
2024-12-13 14:40 MarioBarbero Tag Attached: VisualStudio Code
2024-12-13 14:40 MarioBarbero Tag Attached: NoesisGUI XAML
2024-12-13 14:40 MarioBarbero Tag Detached: xaml;DataContext;IntelliCode;VisualStudio Code;NoesisGUI XAML;
2024-12-13 14:51 MarioBarbero Reproducibility have not tried => always
2024-12-13 14:51 MarioBarbero Note Added: 0010224
2024-12-13 14:51 MarioBarbero File Added: RelayCommand.cs
2024-12-13 17:15 sfernandez Assigned To => maherne
2024-12-13 17:15 sfernandez Status new => assigned
2024-12-13 17:15 sfernandez Product Version 3.2 => 3.2.6
2024-12-13 17:15 sfernandez Target Version => 3.2.7
2025-01-20 17:42 jsantos Target Version 3.2.7 => 3.2.8
2025-06-04 10:17 jsantos Target Version 3.2.8 => 3.2.9
2025-10-02 00:49 jsantos Target Version 3.2.9 => 3.2.10
2025-10-20 18:25 jsantos Target Version 3.2.10 => 3.2.11
2026-01-20 19:32 jsantos Target Version 3.2.11 => 3.2.12
2026-03-04 00:40 jsantos Target Version 3.2.12 => 3.2.13
2026-04-27 12:17 jsantos Target Version 3.2.13 => 3.2.14
2026-10-16 12:07 jsantos Target Version 3.2.14 => 4.0.3