How do i change the image path at run time in wpf ?

I have a button and i need to show image two different image based on condition. 
<Button x:Name="btn" MouseEnter="btn_MouseEnter_1">
<Button.Template>
<ControlTemplate TargetType="Button">
<StackPanel Width="43">
<Image Name="btnS" Source="Resources/main.png" />
</StackPanel>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsEnabled" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="btnS" Property="Source" Value="Resources/hover.png"></Setter>
</MultiTrigger.Setters>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsPressed" Value="True" />
<Condition Property="IsEnabled" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="btnS" Property="Source" Value="Resources/audio-push.png" />
</MultiTrigger.Setters>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="btnS" Property="Source" Value="/Resources/disabled.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
I want to change the source of btnS at run time bases on condition.
Suppose that if a = 1 then 
btnS source is "Resources/main.png" this
else btnS source should be "Resources/main1.png"
same for mouse hover and enable disable triggers.
Thanks,

Hi Sumit,
We can use
VisualTreeHelper class to find Image control in visual tree.
UIHelper.cs:
public class UIHelper
public static T FindChild<T>(DependencyObject parent, string childName)
where T : DependencyObject
// Confirm parent and childName are valid.
if (parent == null) return null;
T foundChild = null;
int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < childrenCount; i++)
var child = VisualTreeHelper.GetChild(parent, i);
// If the child is not of the request child type child
T childType = child as T;
if (childType == null)
// recursively drill down the tree
foundChild = FindChild<T>(child, childName);
// If the child is found, break so we do not overwrite the found child.
if (foundChild != null) break;
else if (!string.IsNullOrEmpty(childName))
var frameworkElement = child as FrameworkElement;
// If the child's name is set for search
if (frameworkElement != null && frameworkElement.Name == childName)
// if the child's name is of the request name
foundChild = (T)child;
break;
else
// child element found.
foundChild = (T)child;
break;
return foundChild;
Code Behind:
private void Button_Click(object sender, RoutedEventArgs e)
Image image1 = UIHelper.FindChild<Image>(btn, "btnS");
if(image1!=null)
image1.Source = new BitmapImage(
new Uri("Resources/main1.png", UriKind.Relative)
Screenshot:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How can i change the image in portal logon screen

    hi guys
    pls tel me
    how can i change the image in portal logon screen
    thanks
    regards
    kamal

    Hi
    Download the par file com.sap.portal.runtime.logon.par.bak from
    Go to System Administration -- Support -- Portal Runtime -- Browse Deployment.
    The path should ROOT/WEB-INF/deployment/pcd. Now download that file into local system.
    Create a Par project and make necessary chenages ..i.e
    Open the downloaded par file with WinZip and inside the lib folder three jar files named com.sap.
    portal.runtime.logon_api.jar, com.sap.portal.runtime.logon_core.jar and umelogonbase.jar will be there. Copy those files in the folder u2018libu2019 in par project.
    Now change a branding Image...i.e
    Replace the branding-image. jpg with your company branding image in the same name.
    Once modifications are done,then create a par project and upload the par file into portal.
    Go to the path System Administration -- Support -- Support Desk -- Portal Runtime -- Administration console.
    then browse the file and click on upload.
    Connect to server where the Portal WebAS is running and go to:
    (drive):\usr\sap\<system id>\<system instance>\j2ee\cluster\server0\apps\sap.com\com.sap.security.core.admin\servlet_jsp\logon\root\layout.
    There you will find the images used on logon screen, you can replace them for your
    company images, please take care with the width of the images, as usual, to make this
    change effective, you must restart the whole WebAS.
    Regards,
    Raju

  • How can i change the default path of installation

    I had creative cloud for a while. Today i changed the default installing folder, from the creative cloud settings/prefferences(can't remember) menu, from C to D. Then i uninstalled all the programs from adobe cs6 to take the new cc programs. When i want to reinstall adobe creative cloud it is installing on D and since there is no operating sistem on D i can't install the creative cloud. It keeps installing on D. How can i change the default path of installation if i uninstalled creative cloud?

    Or how can I change the prefered installation folder that can be changed from creative cloud menu/prefferences when i have uninstalled creative cloud?

  • How can I change the installation path  of JWS?

    I have to install the JRE 1.4.0_01 in silent mode on Windows XP. For the JRE I can set the installation path in the corresponding dialog and record it in an *.iss file. When starting the silent installation the JRE is correctly installed into this path but the Java Webstart installation procedure doesn't care about this path and installs JWS in 'D:\Programme\Java Web Start'.
    How can I change the installation path for JWS?
    J�rg

    Verify Free Disk Space. Assuming you are installing the OS to the C: drive.

  • How do I change the image selected for the finalized movies pane in all events?

    How do I change the image selected for the finalized movies pane in all events? I made a movie some time ago in iMovie, and a still from this now appears as the image for Finalized Movies in the All Events pane (as well as showing up if I then click on this pane to take me to Finalized Movies). Anyone know how to change or delete this image, please?

    Unfortunately, the suggested solution in that thread does not work and the thread appears to be closed to replies.  That is, even though I am logged in the Reply|Quote|Mark as answer|Report as abuse items are missing.
    The suggested solution is:
    First, I found I had "img100.png" in  C:\Windows\Web\Screen  and
    C:\Windows\WinSxS\x86_microsoft-windows-themeui-client_31bf3856ad364e35_6.2.9200.16384_none_69ee3fa2269e545e
    1. Belonging to the Administrators Group, I replaced file Owner TrustedInstaller with my Username on both "img100.png" files
    2. After resizing the image I wanted to see on the Login screen to the resolution of "img100.png" file,
    I copied and pasted it to both "img100.png" files keeping this way the format (extension) and resolution of the original "img100.png" file,
    which I permanently deleted.
    However, I have not been able to replace the img100.pgn in C:\Windows\Web\Screen even after taking ownership of it and setting the permissions for my userid to All.  I edit it with mspaint and then try to save it. The save starts that then says the
    save was interrupted.
    The appears to be some additional protection besides the standard acls.
    http://www.saberman.com

  • How do I change the image title when it is uploaded from iphoto to iweb. At the moment the image title is /shapeimage_1.png and I would like to put in something more relevant than just shapeimage?

    How do I change the image title when it is uploaded from iphoto to iweb. At the moment the image title is /shapeimage_2.png and I would like to put in something more relevant than just shapeimage_2?

    When you drag images from iPhoto to iWeb, iWeb retains the original filename.
    When you use a mask, iWeb creates a png file with the shapeimage name.
    So do not use a mask and crop your images before dropping them on the iWeb canvas.
    When you use an irregularly shaped mask, then png files are created. They have to be png because of the transparency of the shape.
    You can use a 3rd party application to create the png images yourself, and give them a proper name.
    Or use the published png files, rename them and drop them back onto the iWeb canvas, while first removing the previous images.

  • When you drag a link onto your desktop, how do you change the image for the shortcut?

    When you drag a link onto your desktop, how do you change the image for the shortcut?

    Select it, hit command-i (or choose File -> Get Info), select the icon in the info window and paste something else there.

  • How do I change the image used on an movie project icon? iMovie seems to select an image at random from the images I imported.

    How do I change the image used on an movie project icon?
    iMovie seems to select an image at random from the images I imported.

    Not sure I understand how to use what you have posted. Here's what my init() looks like:
    public void init()
    setLayout(new BorderLayout());
    p=new Panel();
    p.setLayout(new GridLayout(1,1));
    callnowButtonURL = getURL(callnowButtonFilename);
    if (callnowButtonURL != null)
    callIcon = new ImageIcon(callnowButtonURL,"call");
    endcallButtonURL = getURL(endcallButtonFilename);
    if (endcallButtonURL != null)
    endIcon = new ImageIcon(endcallButtonURL);
    b=new JButton(callIcon);
    b.setBorder(new EmptyBorder(0,0,0,0));
    b.setBorderPainted(false);
    b.addActionListener(this);
    p.add(b);
    add(p,"Center");
    Now the ActionListener is basically:
    public void actionPerformed(ActionEvent e)
    if (mybool == false)
    <Perform actions here set mybool to true>
    Change JButton b to use EndIcon
    else
    <Perform actions here set mybool to false>
    Change JButton b to use CallIcon
    Can you clarify how to perform the action I require? You can have a couple of Dukes if you can help me sort this out.

  • How Do I Change The Image Used For The Power Up Screen?

    Windows 8.1 Pro with all patches.
    How do I change the image that is shown when you power up a PC?
    Note: This is not the Start Screen background or the Lock Screen background or the Desk Top background.
    http://www.saberman.com

    Unfortunately, the suggested solution in that thread does not work and the thread appears to be closed to replies.  That is, even though I am logged in the Reply|Quote|Mark as answer|Report as abuse items are missing.
    The suggested solution is:
    First, I found I had "img100.png" in  C:\Windows\Web\Screen  and
    C:\Windows\WinSxS\x86_microsoft-windows-themeui-client_31bf3856ad364e35_6.2.9200.16384_none_69ee3fa2269e545e
    1. Belonging to the Administrators Group, I replaced file Owner TrustedInstaller with my Username on both "img100.png" files
    2. After resizing the image I wanted to see on the Login screen to the resolution of "img100.png" file,
    I copied and pasted it to both "img100.png" files keeping this way the format (extension) and resolution of the original "img100.png" file,
    which I permanently deleted.
    However, I have not been able to replace the img100.pgn in C:\Windows\Web\Screen even after taking ownership of it and setting the permissions for my userid to All.  I edit it with mspaint and then try to save it. The save starts that then says the
    save was interrupted.
    The appears to be some additional protection besides the standard acls.
    http://www.saberman.com

  • How can I change the background of a running webpage on my own. Example Facebook I want to change its backround color from white to black just in my view not for all

    How can I change the background of a running webpage on my own. Example Facebook I want to change its background color from white to black just in my view, not for all. Cause I really hate some site with white background because as I read for an hour it aches my eyes but not on those with darker background color.

    You can use the NoSquint extension to set font sizes (text/page zoom) and text colors on web pages.
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/

  • How to change the view criteria at run time for af:query

    Hi,
    I've a usecase where I need to change the view criteria of the af:query at run time.
    Use case:
    =======
    1) Consider a check box (Show Emps Under Dept 10) in the query panel when user selects and clicks 'Search' button should show the employees under dept 10. If user searches without selecting the check box, the results should show all the employees in all the departments.
    2) I need to have a check box always in the query panel. Its mandatory.
    The way I implemented:
    ==============
    1) Created a transient variable 'Show Emps Under Dept 10' in the EmployeeVO and also created a bind variable bind_DeptNo.
    2) Create a view criteria 'AllEmployees' which has only the transient attribute as the view criteria item and whose value set to 'false' by default.
    3) Created another view criteria 'EmpUnderDept' which has 'DepartmentId' as the view criteria item and whose value set to the bind variable 'bind_DeptNo'.
    4) Dropped the view criteria 'EmpUnderDept' as the 'af:query' panel in the jspx page.
    5) Overridden the queryListener as '#{EmpBean.empSearch}'
    6) Has the below code in the empSearch method as below. When user selects the check box, applying the other criteria 'EmpUnderDept' and setting the bind variable to '10'.
    public void empSearch(QueryEvent queryEvent) {
    // Add event code here...
    QueryDescriptor queryDesc = (QueryDescriptor) queryEvent.getDescriptor();
    ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
    List<Criterion> criterionList = conCrit.getCriterionList();
    List criterionValues = new ArrayList();
    Object criteriaValue = null;
    int criteriaNo = 0;
    DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    for (Criterion criterion : criterionList) {
    AttributeDescriptor attrDescriptor = ((AttributeCriterion)criterion).getAttribute();
    System.out.println("============== attrDescriptor.getName() =================== " + attrDescriptor.getName());
    criteriaValue = ((AttributeCriterion)criterion).getValues().get(0);
    if(criteriaNo==0) {
    Boolean val = (Boolean) ((AttributeCriterion)criterion).getValues().get(0);
    if (val.equals(true)) {
    OperationBinding method = (OperationBinding) ADFUtil.findOperation("ExecuteWithParams");
    if(method!=null) {
    Map params = method.getParamsMap();
    //params.put(key, value)
    method.getParamsMap().put("bind_DeptId", 10L);
    method.execute();
    ADFUtil.invokeMethodExpression( "#{bindings.EmpUnderDeptCriteiaQuery.processQuery}", queryEvent);
    } else {
    //ADFUtil.invokeEL("#{bindings.ExecuteWithParams.execute}");
    ADFUtil.invokeMethodExpression( "#{bindings.AllEmployeesCriteriaQuery.processQuery}", queryEvent);
    But this approach is not working and its always showing all the employees in all the departments.
    Please let me know if there is a way to change the view criteria at run time depending on the values set at run time for one of the view criteria items.
    JDev version am using is '11.1.1.5'
    Thanks,
    Lakshman

    Hi Shay,
    It worked for me without overriding the executeQuery() method in the ViewImpl.java.
    Instead of creating 2 view criteria, I created only one which has both transient variable and the DepartmentId = <bind_DeptId>. With the above code, it worked properly. Now I am using only one view criteria.
    Thank you.

  • How We Can Change Page Size During Report Run Time

    Hello !
    How We Can Change Page Size During Report Run Time .
    How can we stop to change the column name when we amend a sql in report data model.
    Thanks !
    null

    hello sohail
    1. question - i'm afraid this cannot be done ... bit in report 6 and newer you have posibility to divide your report in 3 parts (former header, body, trailor) and each part can have diferent page siz, orientation , ...
    2. question - best is give each column in your statements in one report diferent alias. when you have to chnge something, alias will remain same ...
    try this: select 1 as fist_column, 1 as second_column from dual
    hope this helsp

  • How can I change the folder path to my library

    I just changed the file path to my locally stored music from C:\MyStuff\...\iPod Nano Music\... to C:\OneDrive\...\iPod Nano Music\...
    Is there a way I can edit the path that Apple has locally stored to redirect iTunes to the new, correct location instead of (as I've had to do previously) deleting all the music files in iTunes and then adding each music folder back?
    In Advanced Preferences the 'iTunes media folder location' shows as C:\Users\Mark\Music\iTunes\iTunes Media with an edit button. However this is not the location of all my music files (as indicated above).
    Mark

    If you want to move your media to a new path what you should do is edit the media folder preference in iTunes and then consolidate to that new path. Moving the media first by hand and then trying to fix iTunes is generally the wrong approach.
    Your options are to move everything back where it came from, then consolidate to the new path, then delete the originals that iTunes leaves behind. Alternatively you should be able to use my FindTracks script to reconnect the relocated media to iTunes. See this post for an explanation of how it works.
    See also Make a split library portable for reasons why splitting the media folder to a new path may be undesirable.
    tt2

  • How do you change the image in a JPanel?

    Hey! (firstly, i need to use image on a JPanel, label&icon not an option).
    I've made my JPanel class
        public class DrawingPanel extends JPanel {
            Image img;
            DrawingPanel() {
                Image img = Toolkit.getDefaultToolkit().getImage("13.jpg"); //default image at startup
            public void paintComponent (Graphics g) {
                super.paintComponent (g);
                // Use the image width & height to find the starting point
                int imgX = getSize ().width/2 - img.getWidth (this);
                int imgY = getSize ().height/2 - img.getHeight (this);
                //Draw image centered in the middle of the panel   
                g.drawImage (img, 0, 0, this);
            } // paintComponent
        } // DrawingPanelAnd I've made my instance of it and added it to the Frame:
        DrawingPanel imagePanel = new DrawingPanel();Now, I need to change the image on the JPanel according to the user's input. I have the string of the location of the new image. How do I update the JPanel to display this new image? Any help greatly appreciated!!

    Well... You could just add a method in your class which sets the image according to the new image name you provided. Something like this:
        public class DrawingPanel extends JPanel {
            Image img;
            DrawingPanel() {
                img = Toolkit.getDefaultToolkit().getImage("13.jpg"); //default image at startup
            public void setImage(String imageName) {
                    img = Toolkit.getDefaultToolkit().getImage(imageName); //Loading the desired image
            public void paintComponent (Graphics g) {
                super.paintComponent (g);
                // Use the image width & height to find the starting point
                int imgX = getSize ().width/2 - img.getWidth (this);
                int imgY = getSize ().height/2 - img.getHeight (this);
                //Draw image centered in the middle of the panel   
                g.drawImage (img, 0, 0, this);
            } // paintComponent
        } // DrawingPanel

  • How can I change the images for af:statusIndicator?

    The default icons (busy and not busy) have a deep blue background which is different from our chosen background color for the application.
    As per the ADF documentation for Web development Section 16.6:
    "... you can use skins to change the actual image files used in the component."
    Is there any code example on how to change the image file for af:statusIndicator?

    Hi,
    You can check [this post|http://forums.oracle.com/forums/thread.jspa?threadID=615673] for some samples.
    -Arun

Maybe you are looking for

  • Error opening XDP file from Internet Explorer

    Problem: We currently can view pay check online. But users always have problem printing online pay check. So we decided that we will convert online web pay check to PDF so that users can easily print it.<br /><br />We are on Peoplesoft.<br /> - I hav

  • 3.0.02 EA1 - Edit table data in a grid

    Editing table data in a grid is broken in 3.0.02 EA1 under Windows XP Pro SP3 Bug #1: When not in editing mode the cursor keys must move the focus from a cell to cell. Instead an edit mode is activated Bug #2: There is no way to leave cell edit mode

  • Looking for grey desktop wall paper at the start of MacBook Pro  OSX Lion

    Hey guys, I really like the grey wall paper with light texture... the one when you start up MacBook Pro OS Lion and you log in. I'm wondering if anyone know where the file is hiding in computer or anywhere on web to download? I wanna set it as my des

  • How to make use of JApplet's JLayeredPanel?

    My applet has several screens... a loading screen, a login screen, a chat screen, etc. It switches between screens at various times during operation. Here are some snipits from the current code: // Initialization public void init() {      super.init(

  • Help !!! - Webservices not accessible in target systems after transport

    Hi We have a ECC 5.0 box ( WAS 640 ) and have created Webservice definitions and released it to SOAP runtime. We were able to make calls to the this Webservice from external SOAP clients and looks ok. We had this webservice definition ( and its assoc