0

In windows presentation foundation, I have a custom UIControl called EquipmentList. When I intialize it like this in wpf:

<EquipmentList:EquipmentListControl Name="equipmentList" Margin="0,0,2,2"  />

I then try to reference it like this:

InitializeComponent();
this.equipmentList.SetReferenceList(referenceDevices);

I get the error:

Error 1 'Equipment' does not contain a definition for 'equipmentList' and no extension method 'equipmentList' accepting a first argument of type 'FluentGCS.Windows.Equipment' could be found (are you missing a using directive or an assembly reference?)

Resharper doesn't show an error. What's the problem?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
  • Windows foundation presentation, they are different tags, use `WPF` instead. – Sean Vaughn Sep 30 '12 at 04:26
  • try using x:Name instead of Name in your Xaml – Mark Hall Sep 30 '12 at 05:04
  • After adding the XAML, If having issues, I find its good to re-build the solution before referencing it from the code behind. It wouldn't hurt to try. – caesay Sep 30 '12 at 05:09
  • Mark hall, can't you post this as an answer so I can accept it? xD – Christian Stewart Sep 30 '12 at 05:22
  • Another solution (that I prefer) is to hold your custom user controls in a different assembly. That way you can use the Name property and it will be properly mapped to the x:Name and you can use its value in the code-behind. Of course this approach depends on how your solution is structured and it may not always be suitable. If you want your user control in the same assembly then you have to use x:Name as @Mark Hall said. – t.olev Sep 30 '12 at 14:39

1 Answers1

0

Added comment as answer per OP's request.

Try using x:Name instead of Name see accepted answer of this SO question

Community
  • 1
  • 1
Mark Hall
  • 53,938
  • 9
  • 94
  • 111