Resharper 智能感知在 XAML 中似乎不适用于我
我的 Xaml 看起来像
<Window x:Class="GraphicalLuaEditor.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GraphicalLuaEditor"
xmlns:nodeScriptingEditor="clr-namespace:NodeScriptingEditor;assembly=NodeScriptingEditor"
mc:Ignorable="d"
Title="MainWindow">
<DockPanel>
<TextBlock Text="{Binding Test}"/>
</DockPanel>
我的 xaml.cs 看起来像
using System;
using System.Windows;
using System.Windows.Input;
namespace GraphicalLuaEditor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
DataContext = this;
InitializeComponent();
}
public string Test { get; set; } = "ÖÖÖH";
private void CommonCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
throw new NotImplementedException();
}
}
}
当我编辑 XAML 时,我希望它通过建议后面代码中的属性来帮助我进行数据绑定,但事实并非如此。在工作中,我看似没有做任何不同的事情,但它却有效!
此外,它还抱怨由于未知的数据上下文而无法解析符号测试
Intellisense 不适用于 xaml 绑定表达式,除非 DataContext 也在 xaml 中设置。
如果 Windowiteslf 用作 DataContext,则可以使用以下绑定:
<Window DataContext="{Binding RelativeSource={RelativeSource Self}}" ...>
如果有专门的视图模型,可以使用设计时DataContext:
<Window d:DataContext="{d:DesignInstance Type=vm:MyViewModel, IsDesignTimeCreatable=True}" ...>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)