X# and DataContext in XAML
Posted: Mon Jun 05, 2017 10:21 pm
Here is a snippet of my XAML (see attachment for the error):
<UserControl x:Class="xWpfAppDemo.GroupExplorer"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/marku ... ility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:xWpfAppDemo"
xmlns:vm="clr-namespace:xWpfAppDemo.ViewModel"
DataContext="{DynamicResource ViewModelGroupExplorer}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded">
<UserControl.Resources>
<vm:ViewModelGroupExplorer x:Key="ViewModelGroupExplorer"/>
</UserControl.Resources>
While learning about WPF, I came across an article explaining how to set the DataContext in XAML. I was able to do it in C# and X# without making any change to the XAML. The problem I ran into with X# is that it think "vm:ViewModeGroupExplorer" does not exist in namespace "clr-namespace:xWpfAppDemo.ViewModel", but it compile and run no problem at all. But I during development, I don't see what the UI look like, but instead I see "Invalid Markup". So with X# I simply use the code-behind to set the DataContext. This issue is still happening with beta 12. Anyone know how to fix this?
Also, I'm a lazy programmer. Will the General Release improve the intellsense so X# know the properties and methods of my classes? So it will auto complete my typing.
Thanks,
Boonnam
<UserControl x:Class="xWpfAppDemo.GroupExplorer"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/marku ... ility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:xWpfAppDemo"
xmlns:vm="clr-namespace:xWpfAppDemo.ViewModel"
DataContext="{DynamicResource ViewModelGroupExplorer}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded">
<UserControl.Resources>
<vm:ViewModelGroupExplorer x:Key="ViewModelGroupExplorer"/>
</UserControl.Resources>
While learning about WPF, I came across an article explaining how to set the DataContext in XAML. I was able to do it in C# and X# without making any change to the XAML. The problem I ran into with X# is that it think "vm:ViewModeGroupExplorer" does not exist in namespace "clr-namespace:xWpfAppDemo.ViewModel", but it compile and run no problem at all. But I during development, I don't see what the UI look like, but instead I see "Invalid Markup". So with X# I simply use the code-behind to set the DataContext. This issue is still happening with beta 12. Anyone know how to fix this?
Also, I'm a lazy programmer. Will the General Release improve the intellsense so X# know the properties and methods of my classes? So it will auto complete my typing.
Thanks,
Boonnam