Click here to Skip to main content
15,891,775 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all!

I have method which handles Wpf UserControls.

The problem is that some of usercontrols implement interface "MyInterface"
and some usercontrols does not.

I need to call "MyInterface" methods from usercontrols who has that implementation, but since there could be usercontrols without interface method i cannot convert usercontrol blindly eg. like this:

var temp = (userControl as MyInterface);
temp.MyInterfaceMethod();


Hope you got idea :)

Cheers!
Posted
Updated 8-Dec-11 0:57am
v2

1 solution

if(userControl is MyInterface){
    var temp = (userControl as MyInterface);
    temp.MyInterfaceMethod();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900