hi,
I have created template column throught code-behind .In that i custmize the headerTemplate.It contain Image and textbox which placed in stackpanel container.In image we add Tool Tip. It is working with Default style of grid but if i apply custum style to grid then ToolTip is not seen.
Please give the solution....
Thanks in advanced
Hi,
Do you have a sample that shows this problem?
-SteveZ
I write this code in objGrid_ColumnLayoutAssigned
// Code for Cell Template
StringBuilder CellETemp = new StringBuilder();
CellETemp.Append("<DataTemplate ");
CellETemp.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'");
CellETemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>");
CellETemp.Append(" <Grid x:Name=\"LayoutRoot\" Background=\"Transparent\" Width=\"119\">");
CellETemp.Append(" <Grid.ColumnDefinitions>" );
CellETemp.Append(
" <ColumnDefinition x:Name=\"ColValue\" Width=\"117\"></ColumnDefinition>");
" </Grid.ColumnDefinitions>");
" <TextBox x:Name=\"txtValue\" HorizontalAlignment=\"Center\" TextAlignment=\"Right\" Text=\"{Binding " + strHeader + " ,Mode=TwoWay}\" VerticalAlignment=\"Center\" Grid.Column=\"0\" Height=\"20\" Width=\"105\" Background=\"#FFF7F8F8\"></TextBox>");
" </Grid>");CellETemp.Append(" </DataTemplate>");
// Code For Header Template
StringBuilder HeaderTemp = new StringBuilder();
HeaderTemp.Append(
"<DataTemplate ");
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:tooltip='clr-namespace:Silverlight.Controls;assembly=ExtendedControls'> ");
" <StackPanel Orientation= \"Horizontal\">");
" <TextBlock x:Name=\"txtNormal\" Text=\"{Binding Converter={StaticResource HeaderConverter}, ConverterParameter='" + strPeriod + "'}\" HorizontalAlignment=\"Right\" />");
" <Image x:Name=\"imgNotes\" Source= \"../../images/notes.jpg \" Height=\"11\" Width=\"11\" >");
" <tooltip:ToolTipService.ToolTip>" +"<tooltip:ToolTip InitialDelay=\"0\" ShowDuration=\"30\">"+ "<TextBlock x:Name=\"txtNotes\" Text=\"TooltipTest\" Width=\"90\" FontSize=\"11\" FontFamily=\"Arial\" VerticalAlignment=\"Top\" TextAlignment=\"Left\"/>"+"</tooltip:ToolTip>"+"</tooltip:ToolTipService.ToolTip>");
" </Image>");
" </StackPanel>");
" </DataTemplate>");
e.ColumnLayout.Columns.Add(
HeaderText = app.objBizDisplay.PeriodNameDictionary[app.objBizDisplay.ArrPeriodID[icrt]],Key = strHeader, MinimumWidth = 60,
Width =
new ColumnWidth(iWidth, false),IsSortable = false ,IsResizable =true,
HeaderTemplate = (
DataTemplate)XamlReader.Load(HeaderTemp.ToString()),
ItemTemplate = (
DataTemplate)XamlReader.Load(CellTemp.ToString()) });
this code working with Degault Style and i get ToolTip on headerColumn Image of XamGriD.
But If i apply style for Grid either at desinTime or Runtime the Tooltip is not seen
Please Reply...
Thanks for the style.
The issue is that your ContentPresenter is being hidden by your Resizer/Dragger elements, if you put them under the ContentPresenter the tooltip will show up:
<Rectangle x:Name="Resizer" Opacity="0" Fill="AliceBlue" Width="5" Grid.Column="1" StrokeThickness="10"
Cursor="SizeWE" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
<Rectangle x:Name="Dragger" Opacity="0" Stretch="Fill" Fill="AliceBlue" Grid.Column="0" StrokeThickness="10"/>
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" >
</ContentPresenter>
Thank you Steve... Its Work.
But please can u explane me what was the issue.Because i commented Dragger Rectangle then it was also worked.
I havent worked so much on style,ContentPresenter,ControlTemplate etc. so please explane . . .
I believe it's b/c the mouse is being handled on the Dragger rectangle, which mean the tooltip is not getting notified that the mouse is over the contentPresenter.
So you mean ContentPresenter should be last at the ControlTemplate......
It just shouldn't have anything positioned over it. It doesn't have to be last.
Thanks SteveZ