RSS

change tooltips from codebehind silverlight

10 Mar

You can set or change Tooltips from the code behind file.How can i write a code for ToolTip in Code Behind ,so follow this…

ToolTipService.SetToolTip(ButtonName, "This is new tooltip");

find control from codebehind from silverlight:
var button = e.Row.ChildrenOfType<HyperlinkButton>().Where
(b => b.Name == "lbtnStarted").FirstOrDefault();

 //front side
 <telerik:GridViewColumn Width=".2*">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<HyperlinkButton x:Name="lbtnStarted" Content="" 
CommandParameter="{Binding Pkcampaignid}" 
Click="lbtnStarted_click" ToolTipService.ToolTip="Change Status">
</HyperlinkButton>
</DataTemplate>
  </telerik:GridViewColumn.CellTemplate>
 </telerik:GridViewColumn>

//Codebehind

 private void grdcampaign_RowLoaded(object sender,
 Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            if (e.DataElement != null)
            {
                if (e.Row.DataContext != null)
                {
  var button = e.Row.ChildrenOfType<HyperlinkButton>().Where
(b => b.Name == "lbtnStarted").FirstOrDefault();
                    tblcampaign tblst = e.Row.DataContext as tblcampaign;

                    if (Convert.ToString(tblst.Status) == "Running")
                    {
                        button.Content = "Stopped";

ToolTipService.SetToolTip(button, "Change Status to Started");
                    }
                    else if (Convert.ToString(tblst.Status) == "Stopped")
                    {
        ToolTipService.SetToolTip(button, "Change Status to Stopped");
                        button.Content = "Started";
                    }
                    else if (Convert.ToString(tblst.Status) == "Pause")
                    {
      ToolTipService.SetToolTip(button, "Change Status to Started");
                        button.Content = "Started";
                    }

                }
            }
        }
Advertisements
 
Leave a comment

Posted by on March 10, 2012 in Silverlight

 

Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: