C
C#ā€¢4w ago
remi.nz

āœ… Problem with Data Binding

Okay so I'm using Items Control to populate a bunch of Expanders, the expander header is supposed to have two buttons and I'm trying to bind the Commands but it's not working, what's weird is that I've set the Data Context properly and other things like AppIcon, AppName and everything else gets binded properly except for the button Commands and Parameters, can you help me? View.xaml.cs
public partial class StartupApps : UserControl
{
public StartupApps()
{
InitializeComponent();
DataContext = new StartupAppsVM();
}
}
public partial class StartupApps : UserControl
{
public StartupApps()
{
InitializeComponent();
DataContext = new StartupAppsVM();
}
}
ViewModel.cs
public ICommand OpenAppLocation { get; set; }
public ICommand OpenRegLocation { get; set; }

public StartupAppsVM()
{
OpenAppLocation = new RelayCommand(OpenAppLocationCommand);
OpenRegLocation = new RelayCommand(OpenRegLocationCommand);
LoadStartupApps();
}
public ICommand OpenAppLocation { get; set; }
public ICommand OpenRegLocation { get; set; }

public StartupAppsVM()
{
OpenAppLocation = new RelayCommand(OpenAppLocationCommand);
OpenRegLocation = new RelayCommand(OpenRegLocationCommand);
LoadStartupApps();
}
XAML: https://paste.mod.gg/llsvpcqqfqjj/0
No description
12 Replies
remi.nz
remi.nzā€¢4w ago
ignore the first two because I haven't implemented those but why is it looking in the view not the viewmodel šŸ„¹
Unknown User
Unknown Userā€¢4w ago
Message Not Public
Sign In & Join Server To View
remi.nz
remi.nzā€¢4w ago
Even if I bind it normally like Command={Binding OpenAppLocation} it doesn't work I tried ElementName as well
Unknown User
Unknown Userā€¢4w ago
Message Not Public
Sign In & Join Server To View
remi.nz
remi.nzā€¢4w ago
Yes idk why
Unknown User
Unknown Userā€¢4w ago
Message Not Public
Sign In & Join Server To View
remi.nz
remi.nzā€¢4w ago
It's driving me crazy cuz it's the only View which has binding errors
Unknown User
Unknown Userā€¢4w ago
Message Not Public
Sign In & Join Server To View
remi.nz
remi.nzā€¢4w ago
Alr
Klarth
Klarthā€¢4w ago
RelativeSource binds to a control, not a VM. Command="{Binding DataContext.OpenRegLocation, RelativeSource=... is what you should be trying
remi.nz
remi.nzā€¢4w ago
Still the same ok nvm it works just fine now thank you so much ā¤ļø !close
Accord
Accordā€¢4w ago
Closed!