Context: I am prototyping to prepare (possibly) converting my WinForms application to WPF.
I am making a very simple tree view event handler for which this code:
var treeViewItem = (TreeViewItem)e.NewValue; var treeViewItemTag = treeViewItem.Tag; if (treeViewItemTag == "ViewForAMs") { ObjectQuery<AccountManagerView> oq = entities.AccountManagerViews; var q = from c in oq select c; dataGrid1.ItemsSource = q.ToList(); }
and xaml:
<Window x:Class="AccountingWpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"> <DockPanel> <TreeView Name="treeView1" ItemsSource="{Binding Folders}" SelectedItemChanged="treeView1_SelectedItemChanged"> <TreeViewItem Header="Account Manager View" Tag="ViewForAMs"/> </TreeView> <DataGrid AutoGenerateColumns="True" Name="dataGrid1" /> </DockPanel> </Window>
When I launched it, I completely expected to see that my data grid is full, but the comparison == happened in the second line of code above.
The debugger shows this:
QUESTION: why there were no compilation errors or runtime? (the same question is different: what is actually being compared, so does the == operator output FALSE?)

Aaron anodide
source share