• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

WPF: Extending the list view (problem using extended object)

G

Griff

#1
I have a window with multiple ListViews in them.

When someone right-clicks on any of the listview items, then I want a
context menu to appear and one of the options is to copy the data displayed
to the clipboard.

For a single listView this is simple - I just use the right-mouse-click
event. However, as said, I've loads of these listViews and more will be
added in future, so I don't want to keep creating event handlers for every
instance.

So, I decided to go down the inheritance route.

I created a Class called "ListViewExtClass" which inherits from the
ListView. I changed the on-right-mouse-click event so that it has the
necessary code. Now to use it.

In the XAML <Window/> element, I tried to add the xmlns:local definition.
When I type in "xmlns:local=" it then gives me a list of options....one of
which is my project. I select it, so I now end up with
'xmlns:local="clr-namespace:MyProjectName" '. The only problem is that this
now displays with a squiggle under it. This expands to say "Assembly
'MyProjectName' was not found. Verify that you are not missing an assembly
reference. Also, verify that your project and all reference assemblies have
been built".

There are no DLLs etc, so everything is "within" the EXE.

I clicked on "MyProject" and went to the References tab. In the lower
listview, I found "MyApplicationName" in the list, but it was unticked. I
ticked it, but this has not solved the problem. I reversed this change.

It's something trivial I'm sure, but don't know what it is. All help most
appreciated.

Thanks

Griff
 

My Computer

K

Karsten Schlender

#2
I know this problem in VS 2005, but there it is a mere designer issue,
compilation should be possible.
Does this apply to you?

Karsten

Griff schrieb:

> I have a window with multiple ListViews in them.
>
> When someone right-clicks on any of the listview items, then I want a
> context menu to appear and one of the options is to copy the data displayed
> to the clipboard.
>
> For a single listView this is simple - I just use the right-mouse-click
> event. However, as said, I've loads of these listViews and more will be
> added in future, so I don't want to keep creating event handlers for every
> instance.
>
> So, I decided to go down the inheritance route.
>
> I created a Class called "ListViewExtClass" which inherits from the
> ListView. I changed the on-right-mouse-click event so that it has the
> necessary code. Now to use it.
>
> In the XAML <Window/> element, I tried to add the xmlns:local definition.
> When I type in "xmlns:local=" it then gives me a list of options....one of
> which is my project. I select it, so I now end up with
> 'xmlns:local="clr-namespace:MyProjectName" '. The only problem is that this
> now displays with a squiggle under it. This expands to say "Assembly
> 'MyProjectName' was not found. Verify that you are not missing an assembly
> reference. Also, verify that your project and all reference assemblies have
> been built".
>
> There are no DLLs etc, so everything is "within" the EXE.
>
> I clicked on "MyProject" and went to the References tab. In the lower
> listview, I found "MyApplicationName" in the list, but it was unticked. I
> ticked it, but this has not solved the problem. I reversed this change.
>
> It's something trivial I'm sure, but don't know what it is. All help most
> appreciated.
>
> Thanks
>
> Griff
>
>
 

My Computer

G

Griff

#3
Hi Karsten

Unfortunately not...

If I create a <ListView Name="abc"/> then this can be found in the code:
me.abc

However, if I create <local:ListViewExtended Name="abc"/> then "me.abc"
errors saying that "abc" is unknown.

Griff
 

My Computer

R

Radek Cerny

#5
try use x:Name="abc". It might be getting its namespaces confused.

"Griff" <GriffithsJ_520@xxxxxx> wrote in message
news:%23xzo11TeIHA.1164@xxxxxx

> Hi Karsten
>
> Unfortunately not...
>
> If I create a <ListView Name="abc"/> then this can be found in the code:
> me.abc
>
> However, if I create <local:ListViewExtended Name="abc"/> then "me.abc"
> errors saying that "abc" is unknown.
>
> Griff
>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)