Understanding FindName

G

Gordon Padwick

I've spent the last few days trying to understand how to use FindName. I
have some success, but problems remain.

Unfortunately, the books aboout C# and WPF I have don't contain detailed
information about FindName--perhaps they do, but if so, the indexes don't
refer to it (that's a major complaint I have about computer books--their
indexes don't adequately refer to the subject matter).

One of the most helpful resources I've found to help me understand FindName
is the Visual Studio 2008 help topic "Finding Template-Generated Elements
Sample.".

The sample contains some code that I don't understand and about which I
haven't been able to find information.

The Windows1.xaml file contains the directive:
xmlns:local=clr-namespace:FindGeneratedItems

Can someone explain significance of "xmlns:local"? I find this frequently
used in examples, but haven't been able to find an explanation.

The definition of a StackPanel in the same sample contains:
XPath="Books/Book"

What is XPath? What is the significance of "Books/Book"?

I'll greatly appreciate specific answers or pointers to sources of
information.

Gordon Padwick
 
P

Pavel Minaev

I've spent the last few days trying to understand how to use FindName. I
have some success, but problems remain.

Unfortunately, the books aboout C# and WPF I have don't contain detailed
information about FindName--perhaps they do, but if so, the indexes don't
refer to it (that's a major complaint I have about computer books--their
indexes don't adequately refer to the subject matter).

Normally, it's because if you want detailed description of one
particular type or member, it is generally available on MSDN; e.g.:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname.aspx
The sample contains some code that I don't understand and about which I
haven't been able to find information.

The Windows1.xaml file contains the directive:
xmlns:local=clr-namespace:FindGeneratedItems

Can someone explain significance of "xmlns:local"? I find this frequently
used in examples, but haven't been able to find an explanation.

This is an XML namespace declaration. It has the form of an attribute,
starting with "xmlns:" (XML NameSpace), followed by the prefix that
you're binding. The value of the attribute is namespace URI, which
actually defines the namespace (so if you bind two different prefixes
to the same URI, they represent the same namespace). "clr-namespace:"
URI scheme corresponds to .NET namespaces - in this case, it's
presumably the namespace in which types in your project live.

XML namespaces (without WPF-specific details, naturally) are defined
by the following W3C specification:

http://www.w3.org/TR/REC-xml-names/
The definition of a StackPanel in the same sample contains:
XPath="Books/Book"

What is XPath? What is the significance of "Books/Book"?

XPath is a selector/query language for XML data. It is defined by the
following W3C specification:

http://www.w3.org/TR/xpath

"Books/Book" is an XPath expression meaning "all elements with name
'Book' that are children of all elements with name 'Books' that are
children of the current element". It's read roughly like a path, where
in Unix, traditionally, you use "/" to reference a file or a
subdirectory in a directory. In XPath, you use "/" to reference
children of an XML element. In context of the WPF binding, current
element (which can be referenced in XPath by dot, ".") is
Binding.Source.
 
P

Pavel Minaev

I've spent the last few days trying to understand how to use FindName. I
have some success, but problems remain.

Unfortunately, the books aboout C# and WPF I have don't contain detailed
information about FindName--perhaps they do, but if so, the indexes don't
refer to it (that's a major complaint I have about computer books--their
indexes don't adequately refer to the subject matter).

Normally, it's because if you want detailed description of one
particular type or member, it is generally available on MSDN; e.g.:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname.aspx
The sample contains some code that I don't understand and about which I
haven't been able to find information.

The Windows1.xaml file contains the directive:
xmlns:local=clr-namespace:FindGeneratedItems

Can someone explain significance of "xmlns:local"? I find this frequently
used in examples, but haven't been able to find an explanation.

This is an XML namespace declaration. It has the form of an attribute,
starting with "xmlns:" (XML NameSpace), followed by the prefix that
you're binding. The value of the attribute is namespace URI, which
actually defines the namespace (so if you bind two different prefixes
to the same URI, they represent the same namespace). "clr-namespace:"
URI scheme corresponds to .NET namespaces - in this case, it's
presumably the namespace in which types in your project live.

XML namespaces (without WPF-specific details, naturally) are defined
by the following W3C specification:

http://www.w3.org/TR/REC-xml-names/
The definition of a StackPanel in the same sample contains:
XPath="Books/Book"

What is XPath? What is the significance of "Books/Book"?

XPath is a selector/query language for XML data. It is defined by the
following W3C specification:

http://www.w3.org/TR/xpath

"Books/Book" is an XPath expression meaning "all elements with name
'Book' that are children of all elements with name 'Books' that are
children of the current element". It's read roughly like a path, where
in Unix, traditionally, you use "/" to reference a file or a
subdirectory in a directory. In XPath, you use "/" to reference
children of an XML element. In context of the WPF binding, current
element (which can be referenced in XPath by dot, ".") is
Binding.Source.
 
G

Gordon Padwick

Thanks as always, Pavel, for taking the time to provide detailed responses
to my questions. I, and probably many other people, appreciate your
willingness to share your knowldge.

Gordon

I've spent the last few days trying to understand how to use FindName. I
have some success, but problems remain.

Unfortunately, the books aboout C# and WPF I have don't contain detailed
information about FindName--perhaps they do, but if so, the indexes don't
refer to it (that's a major complaint I have about computer books--their
indexes don't adequately refer to the subject matter).

Normally, it's because if you want detailed description of one
particular type or member, it is generally available on MSDN; e.g.:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname.aspx
The sample contains some code that I don't understand and about which I
haven't been able to find information.

The Windows1.xaml file contains the directive:
xmlns:local=clr-namespace:FindGeneratedItems

Can someone explain significance of "xmlns:local"? I find this frequently
used in examples, but haven't been able to find an explanation.

This is an XML namespace declaration. It has the form of an attribute,
starting with "xmlns:" (XML NameSpace), followed by the prefix that
you're binding. The value of the attribute is namespace URI, which
actually defines the namespace (so if you bind two different prefixes
to the same URI, they represent the same namespace). "clr-namespace:"
URI scheme corresponds to .NET namespaces - in this case, it's
presumably the namespace in which types in your project live.

XML namespaces (without WPF-specific details, naturally) are defined
by the following W3C specification:

http://www.w3.org/TR/REC-xml-names/
The definition of a StackPanel in the same sample contains:
XPath="Books/Book"

What is XPath? What is the significance of "Books/Book"?

XPath is a selector/query language for XML data. It is defined by the
following W3C specification:

http://www.w3.org/TR/xpath

"Books/Book" is an XPath expression meaning "all elements with name
'Book' that are children of all elements with name 'Books' that are
children of the current element". It's read roughly like a path, where
in Unix, traditionally, you use "/" to reference a file or a
subdirectory in a directory. In XPath, you use "/" to reference
children of an XML element. In context of the WPF binding, current
element (which can be referenced in XPath by dot, ".") is
Binding.Source.
 
G

Gordon Padwick

Thanks as always, Pavel, for taking the time to provide detailed responses
to my questions. I, and probably many other people, appreciate your
willingness to share your knowldge.

Gordon

I've spent the last few days trying to understand how to use FindName. I
have some success, but problems remain.

Unfortunately, the books aboout C# and WPF I have don't contain detailed
information about FindName--perhaps they do, but if so, the indexes don't
refer to it (that's a major complaint I have about computer books--their
indexes don't adequately refer to the subject matter).

Normally, it's because if you want detailed description of one
particular type or member, it is generally available on MSDN; e.g.:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname.aspx
The sample contains some code that I don't understand and about which I
haven't been able to find information.

The Windows1.xaml file contains the directive:
xmlns:local=clr-namespace:FindGeneratedItems

Can someone explain significance of "xmlns:local"? I find this frequently
used in examples, but haven't been able to find an explanation.

This is an XML namespace declaration. It has the form of an attribute,
starting with "xmlns:" (XML NameSpace), followed by the prefix that
you're binding. The value of the attribute is namespace URI, which
actually defines the namespace (so if you bind two different prefixes
to the same URI, they represent the same namespace). "clr-namespace:"
URI scheme corresponds to .NET namespaces - in this case, it's
presumably the namespace in which types in your project live.

XML namespaces (without WPF-specific details, naturally) are defined
by the following W3C specification:

http://www.w3.org/TR/REC-xml-names/
The definition of a StackPanel in the same sample contains:
XPath="Books/Book"

What is XPath? What is the significance of "Books/Book"?

XPath is a selector/query language for XML data. It is defined by the
following W3C specification:

http://www.w3.org/TR/xpath

"Books/Book" is an XPath expression meaning "all elements with name
'Book' that are children of all elements with name 'Books' that are
children of the current element". It's read roughly like a path, where
in Unix, traditionally, you use "/" to reference a file or a
subdirectory in a directory. In XPath, you use "/" to reference
children of an XML element. In context of the WPF binding, current
element (which can be referenced in XPath by dot, ".") is
Binding.Source.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top