简体   繁体   中英

Is is possible to enable intellisense for XAML binding to view model?

I always used such obvious names for my fields in the view model so that I actually don't need the intellisense. However, I just discovered that I'd need it when working with code from programmers insisting on using non-english names (because " coding is much easier when one uses the native tongue ").

So the question is - is it possible to make XAML intellisense to provide me with the list of fields in the view model (easily, that is)?

C#

public ElViewoConstructo()
{
  InitializeComponent();
  DataContext = new ElViewoModello();
}

XAML

<ProgressBar Maximum="{Binding Path=Donkey}"
             Minimum="0"
             Value="{Binding Path=Monkey}"
             Visibility="{Binding Path=Wonkey.Bonky}" />

If it's possible, I'm guessing that I'd need to register the data context in some way. Surprisingly though, I couldn't find anything useful by Google. It's possible that I'm using a wrong set of search words but I got only intellisense questions on SQL Management Studio...

Either set the DataContext in XAML:

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

or use d:DataContext to define the design-time DataContext type:

<Window d:DataContext="{d:DesignInstance local:ElViewoModello}"/>

You may need to add

xmlns:mc="schemas.openxmlformats.org/markup-compatibility/2006"  
mc:Ignorable="d" 

to your xaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM