RSS

How can i set ToolTip in CodeBehind using Silverlight

20 Mar

hi dear……

ToolTipService.SetToolTip(btnButtonName, “Disable Due to Campaign Currently ” );

 showing a tooltip for disabled control in silverlight CodeBehind

private void grdcampaign_RowLoaded(object sender, RowLoadedEventArgs e)
{

if (e.DataElement != null)
{
if (e.Row.DataContext != null)
{
var btnDelete = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnDelete”).FirstOrDefault();
var btnView = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnView”).FirstOrDefault();

//btnView6
tblcampaign tblst = e.Row.DataContext as tblcampaign;
if (Convert.ToString(tblst.Status) != “Pending”)
{

btnView.IsEnabled = false;
//this Line Show the Tooltip of Disable Button
ToolTipService.SetToolTip(e.Row.Cells[8], “Campaign Currently  ” + tblst.Status);

}
else
{
btnView.IsEnabled = true;
ToolTipService.SetToolTip(btnView, “Campaign Currently  ” + tblst.Status);

}

}
}

}

                     //How can i find RadGridview or datagridview Button Codebehind in Silverlight

var btnDelete = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnDelete”).FirstOrDefault();

.xaml Side

<telerik:RadGridView x:Name=”grdcampaign” Grid.Row=”2″ Grid.Column=”0″ IsFilteringAllowed=”False”
LoadingRowDetails=”grdcampaign_LoadingRowDetails” RowLoaded=”grdcampaign_RowLoaded”
ColumnWidth=”*”    RowIndicatorVisibility=”Collapsed”
IsReadOnly=”True” AutoGenerateColumns=”False” CanUserFreezeColumns=”False”
CanUserResizeColumns=”False” MinWidth=”1000″  Style=”{StaticResource DefaultGridStyle}”>

<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<!–<telerik:GridViewImageColumn IsGroupable=”False” IsSortable=”False”
DataMemberBinding=”{Binding Image}” Width=”50″ ImageHeight=”40″ ImageWidth=”40″ />–>
<telerik:GridViewDataColumn UniqueName=”Campaigndesc” Header=”Campaign Name” Width=”.2*”/>
<telerik:GridViewDataColumn UniqueName=”CompanyName” Header=”Company Name” Width=”.1*” />

<telerik:RadButton x:Name=”btnView” Command=”Edit”
CommandParameter=”{Binding Campaignidpk}” BorderThickness=”1″
ToolTipService.ToolTip=”View Leads”  Click=”RadButton_Click”>
<telerik:RadButton.Content>
<StackPanel Orientation=”Horizontal” Margin=”0″ x:Name=”btnView6″  >
<Image Source=”../Images/icon-view.png” Width=”15″ Height=”15″/>
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

<telerik:GridViewColumn Width=”28″>
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<telerik:RadButton  x:Name=”btnDelete” Command=”Delete”
CommandParameter=”{Binding Campaignidpk}”
BorderThickness=”1″ Click=”btnDelete_click” ToolTipService.ToolTip=”Delete” >
<telerik:RadButton.Content>
<StackPanel Orientation=”Horizontal” Margin=”0″>
<Image Source=”../Images/icon-delete.png” Width=”15″ Height=”15″/>
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate >
<DataTemplate>

<StackPanel Orientation=”Horizontal” HorizontalAlignment=”Stretch”  Margin=”5″ MinWidth=”800″>
<my1:ListCampaignDetail x:Name=”ListCampaignDetail1″ MinWidth=”800″/>

</StackPanel>

</DataTemplate>

</telerik:RadGridView.RowDetailsTemplate>

<i:Interaction.Behaviors>
<local:EmptyDataTemplateBehavior>
<local:EmptyDataTemplateBehavior.EmptyDataTemplate>
<DataTemplate>
<TextBlock Text=”No results found!” Foreground=”red”
HorizontalAlignment=”Center”  VerticalAlignment=”Center” />
</DataTemplate>
</local:EmptyDataTemplateBehavior.EmptyDataTemplate>
</local:EmptyDataTemplateBehavior>
</i:Interaction.Behaviors>
</telerik:RadGridView>
<telerik:RadDataPager Grid.Column=”0″ Grid.Row=”3″ PageSize=”20″ DisplayMode=”All”
AutoEllipsisMode=”Both” NumericButtonCount=”10″ IsTotalItemCountFixed=”True”
Source=”{Binding Items, ElementName=grduser}” />

//How To Get ID of Selected Row in RadGridView

RadButton btnEdit = sender as RadButton;
int Cid = Convert.ToInt32(btnEdit.CommandParameter);

Advertisements
 
Leave a comment

Posted by on March 20, 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: