Telerik Forums
UI for WPF Forum
4 answers
223 views
Hi,

I'm creating a chart that is based off the MeteoChart example. Specifically, I'm using the same concepts as the SplineLabelStyle in the MeteoChart to display custom icons overriding the default item label.

The MeteoChart has the following XAML to style the SeriesItemLabel with a custom control template that contains custom icons:
<Style x:Key="SplineLabelStyle" TargetType="charting:SeriesItemLabel">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="charting:SeriesItemLabel">
                <Canvas>
                    <Border x:Name="PART_TextContainer">
                        <Image x:Name="PART_Image"
                              Source="{Binding DataItem.WeatherImageSource}" />
                    </Border>
                </Canvas>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

What I'd like to do is add a tooltip to this image to display more information, ie:
<Style x:Key="SplineLabelStyle" TargetType="charting:SeriesItemLabel">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="charting:SeriesItemLabel">
                <Canvas>
                    <Border x:Name="PART_TextContainer">
                        <Image x:Name="PART_Image"
                              Source="{Binding DataItem.WeatherImageSource}"
                              ToolTip="{Binding DataItem.WeatherConditions}" />
                    </Border>
                </Canvas>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

The problem is that the above XAML doesn't work. While the example runs, tooltips are not displayed when hovering over the icon. I've tried shifting the tooltip to the canvas instead and even tried displaying fixed text as the tooltip, however none of these alternatives get tooltips to display.

I would like to display the tooltip on the customized item label because:
  1. these labels are easier targets to hover over instead of point marks,
  2. the labels are displayed in a different location to the point mark, and finally
  3. I'm actually hiding the point mark in my actual scenario (I'm just displaying the icons).

How can I define tooltips for custom item labels?

Alternatively, how can I customize the PointMarkItemStyle to display custom icons (and then I can use the default item tooltip provided).

Kind regards,
Dave.

Evgenia
Telerik team
 answered on 06 Apr 2012
1 answer
190 views
I am doing a search/replace in code using the RadDocument and I am getting a strange null error.

Here is the code:
doc.Selection.Clear();
            DocumentTextSearch search = new DocumentTextSearch(doc);
            var rangesTrackingDocumentChanges = new List<TextRange>();
            var resultRanges = search.FindAll(searchText);
 
            foreach (var textRange in resultRanges)
            {
                TextRange newRange = new TextRange(new DocumentPosition(textRange.StartPosition, true), new DocumentPosition(textRange.EndPosition, true));
                rangesTrackingDocumentChanges.Add(newRange);
            }
 
            foreach (var textRange in rangesTrackingDocumentChanges)
            {
                doc.CaretPosition.MoveToPosition(textRange.StartPosition);
                doc.DeleteRange(textRange.StartPosition, textRange.EndPosition);
                doc.Insert(mergeText, new Telerik.Windows.Documents.Model.Styles.StyleDefinition());
                textRange.StartPosition.Dispose();
                textRange.EndPosition.Dispose();
            }


When the RadDocument is simple,this works fine, however, when I put the Merge fields in Tables, it is throwing an error on the search.FindAll() method:

System.NullReferenceException: Object reference not set to an instance of an object.
  "   at Telerik.Windows.Documents.TextSearch.DocumentTextMap.MoveToFirstBoxInWord(DocumentPosition position) in c:\\TB\\102\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Documents\\Core\\TextSearch\\DocumentTextMap.cs:line 313\r\n   at Telerik.Windows.Documents.TextSearch.DocumentTextMap.InitMap(DocumentPosition fromPosition, DocumentPosition toPosition) in c:\\TB\\102\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Documents\\Core\\TextSearch\\DocumentTextMap.cs:line 115\r\n   at Telerik.Windows.Documents.TextSearch.DocumentTextSearch.FindInternal(String regEx, DocumentPosition fromPosition, DocumentPosition toPosition, Boolean findFirst) in c:\\TB\\102\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Documents\\Core\\TextSearch\\DocumentTextSearch.cs:line 90\r\n   at Telerik.Windows.Documents.TextSearch.DocumentTextSearch.FindAll(String regEx) in c:\\TB\\102\\WPF_Scrum\\Release_WPF\\Sources\\Development\\Documents\\Core\\TextSearch\\DocumentTextSearch.cs:line 52\r\n   at Service.ServiceHandler.Documentation.DocDataMgr.MergeText(RadDocument doc, String mergeName, String mergeText) in N:\\BMS\\svn_r3\\Rf3Db\\Service\\ServiceHandler\\Documentation\\DocDataMgr.cs:line 947"

Here is the text I am searching for:   "{ MERGEFIELD TmHeader }"

Here is the RadDocument:  
"<t:RadDocument xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:t=\"clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents\" xmlns:s=\"clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents\" version=\"1.2\" LayoutMode=\"Flow\" LineSpacing=\"1.14999997615814\" LineSpacingType=\"Auto\" ParagraphDefaultSpacingAfter=\"12\" ParagraphDefaultSpacingBefore=\"0\" SectionDefaultPageSize=\"816,1056\" StyleName=\"defaultDocumentStyle\">\r\n  <t:RadDocument.ProtectionSettings>\r\n    <t:DocumentProtectionSettings EnableDocumentProtection=\"False\" Enforce=\"False\" HashingAlgorithm=\"None\" HashingSpinCount=\"0\" ProtectionMode=\"ReadOnly\" />\r\n  </t:RadDocument.ProtectionSettings>\r\n  <t:RadDocument.Styles>\r\n    <s:StyleDefinition DisplayName=\"Document Default Style\" IsCustom=\"False\" IsDefault=\"False\" IsPrimary=\"True\" Name=\"defaultDocumentStyle\" Type=\"Default\">\r\n      <s:StyleDefinition.ParagraphStyle>\r\n        <s:ParagraphProperties LineSpacing=\"1.14999997615814\" SpacingAfter=\"12\" />\r\n      </s:StyleDefinition.ParagraphStyle>\r\n      <s:StyleDefinition.SpanStyle>\r\n        <s:SpanProperties FontFamily=\"Verdana\" FontSize=\"16\" FontStyle=\"Normal\" FontWeight=\"Normal\" />\r\n      </s:StyleDefinition.SpanStyle>\r\n    </s:StyleDefinition>\r\n    <s:StyleDefinition BasedOnName=\"TableNormal\" DisplayName=\"TableGrid\" IsCustom=\"False\" IsDefault=\"False\" IsPrimary=\"True\" Name=\"TableGrid\" Type=\"Table\">\r\n      <s:StyleDefinition.ParagraphStyle>\r\n        <s:ParagraphProperties LineSpacing=\"1\" SpacingAfter=\"0\" />\r\n      </s:StyleDefinition.ParagraphStyle>\r\n      <s:StyleDefinition.TableStyle>\r\n        <s:TableProperties Borders=\"1,Single,#FF000000\" />\r\n      </s:StyleDefinition.TableStyle>\r\n    </s:StyleDefinition>\r\n    <s:StyleDefinition DisplayName=\"TableNormal\" IsCustom=\"False\" IsDefault=\"True\" IsPrimary=\"True\" Name=\"TableNormal\" Type=\"Table\" />\r\n  </t:RadDocument.Styles>\r\n  <t:Section>\r\n    <t:Paragraph TextAlignment=\"Left\">\r\n      <t:Paragraph.TabStops>\r\n        <t:TabStop Position=\"208\" TabStopType=\"Left\" />\r\n      </t:Paragraph.TabStops>\r\n    </t:Paragraph>\r\n    <t:Paragraph TextAlignment=\"Left\">\r\n      <t:Paragraph.TabStops>\r\n        <t:TabStop Position=\"208\" TabStopType=\"Left\" />\r\n      </t:Paragraph.TabStops>\r\n      <t:Span Text=\"{}{ MERGEFIELD TmDate } { MERGEFIELD TmLeft }{ MERGEFIELD TmRight }\" />\r\n    </t:Paragraph>\r\n    <t:Paragraph TextAlignment=\"Left\">\r\n      <t:Paragraph.TabStops>\r\n        <t:TabStop Position=\"208\" TabStopType=\"Left\" />\r\n      </t:Paragraph.TabStops>\r\n    </t:Paragraph>\r\n    <t:Table GridColumnWidthsSerializationInfo=\"\" LayoutMode=\"AutoFit\" PreferredWidth=\"Auto\" StyleName=\"TableGrid\" TableIndent=\"0\">\r\n      <t:TableRow>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph>\r\n            <t:Span Text=\" { MERGEFIELD TmHeader } \" />\r\n          </t:Paragraph>\r\n        </t:TableCell>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph />\r\n        </t:TableCell>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph />\r\n        </t:TableCell>\r\n      </t:TableRow>\r\n      <t:TableRow>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph />\r\n        </t:TableCell>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph />\r\n        </t:TableCell>\r\n        <t:TableCell ColumnSpan=\"1\" RowSpan=\"1\">\r\n          <t:Paragraph />\r\n        </t:TableCell>\r\n      </t:TableRow>\r\n    </t:Table>\r\n    <t:Paragraph TextAlignment=\"Left\">\r\n      <t:Paragraph.TabStops>\r\n        <t:TabStop Position=\"208\" TabStopType=\"Left\" />\r\n      </t:Paragraph.TabStops>\r\n    </t:Paragraph>\r\n  </t:Section>\r\n</t:RadDocument>"

Martin Ivanov
Telerik team
 answered on 06 Apr 2012
3 answers
91 views
Hello,

I'm looking to stack a chart on top of an existing chart, that scrolls along the same timeline as the bottom chart.  Something like this:

http://www.google.com/finance?q=NASDAQ%3AMSFT

Any guidance on how to do this?

Thank you,
Michael
Bartholomeo Rocca
Top achievements
Rank 1
 answered on 06 Apr 2012
1 answer
139 views
How do I format the GanttView Columns displaying Custom formats?
I have try to set the StringFormat like this:
<telerik:ColumnDefinition MemberBinding="{Binding End , StringFormat={}{0:d}}" Header="End" ColumnWidth="100" >
                     <telerik:ColumnDefinition.CellEditTemplate>
                     <DataTemplate>
                         <telerik:RadDatePicker SelectedValue="{Binding End,Mode=TwoWay}" />
                     </DataTemplate>
                 </telerik:ColumnDefinition.CellEditTemplate>
             </telerik:ColumnDefinition>

But it does not work.

As a workaround i have done following in my custom tasks class:
public String End_str
{
    get
    {
        return base.End.ToString("yyyy-MM-dd"); 
    }
}



Br /Sture
Miroslav Nedyalkov
Telerik team
 answered on 06 Apr 2012
2 answers
320 views
Good afternoon,

I'm having an issue with RadComboBox binding. I'm implementing iNotifyPropertyChanged which works with both get and set properties.
When I change my selection in the RadComboBox the propertychanged event is raised and works fine.
However, I have IsEditable="True" & IsReadOnly="True" set
telerik:RadComboBox x:Name="comboCounties" Grid.Row="4" Grid.Column="1" MinWidth="200" IsEditable="True"
                                     IsReadOnly="True" StaysOpenOnEdit="True" EmptyText="Please select a county" SelectedIndex="-1"
                                     DisplayMemberPath="County" SelectedValuePath="ID" Margin="5"
                                     Style="{StaticResource ComboBoxErrorToolTip}">
                    <telerik:RadComboBox.SelectedValue>
                        <Binding Path="CountyID" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule></DataErrorValidationRule>
                            </Binding.ValidationRules>
                        </Binding>
                    </telerik:RadComboBox.SelectedValue>
                </telerik:RadComboBox>


When I delete all of the text in the ComboBox using the keyboard "back space" key the property changed event isn't raised.
i.e. I would expect the selected index to be -1 again and the selected value to clear to some default.

Any idea how I can get around this?

This problem came to light because my DataErrorValidationRule isn't working properly if the selected ComboBox text has been fully deleted after a selection was made.

When viewing the Validation Error in a message box it reads 'Value " could not be converted.'

Here's my validation code for your reference:

private void GetErrors(StringBuilder sb, DependencyObject obj)
{
    foreach (object child in LogicalTreeHelper.GetChildren(obj))
    {
        if (child is TextBox)
        {
            TextBox element = child as TextBox;
            if (element == null) continue;
 
            if (Validation.GetHasError(element))
            {
                sb.Append(element.Text + "Missing detail:\r\n");
                foreach (ValidationError error in Validation.GetErrors(element))
                {
                    sb.Append(error.ErrorContent.ToString());
                    sb.Append("\r\r");
                }
            }
            //Check the children of this object for errors
            GetErrors(sb, element);
        }
        if (child is RadComboBox)
        {
            RadComboBox element = child as RadComboBox;
            if (element == null) continue;
 
            if (Validation.GetHasError(element))
            {
                sb.Append("Missing detail:\r\n");
                foreach (ValidationError error in Validation.GetErrors(element))
                {
                    sb.Append(error.ErrorContent.ToString());
                    sb.Append("\r\r");
                }
            }
            //Check the children of this object for errors
            GetErrors(sb, element);
        }
    }
}


//DataErrorValidationRule
public string this[string propertyName]
{
    get
    {
        if (propertyName == "Address1")
        {
            if (string.IsNullOrEmpty(Address1))
            {
                return "Line 1 is required.";
            }
        }
        if (propertyName == "Postcode")
        {
            if (string.IsNullOrEmpty(Postcode))
            {
                return "Postcode is required.";
            }
        }
        if (propertyName == "CountyID")
        {
            if (CountyID <= 0)
            {
                return "County is required.";
            }
        }
        return null;
    }
}
//WPF Doesn't use this property
public string Error
{
    get { return null; }
}

Thank you for your time,

Rob
Konstantina
Telerik team
 answered on 06 Apr 2012
1 answer
297 views

Q1 2012

I have a RadGridView that I am binding to a DataTable. The DataTable is dynamically generated in code. In the first column of the DataTable there is an object. I have an event attached to the RowLoaded event. In the RowLoaded event I want to set the template of the first cell to a Resource Template. This is the code I am using but the cell is always empty.

XAML Template

<ControlTemplate x:Key="FluidEditorTemplate">
                <shared:PopupButton PopupHorizontalOffset="0" HorizontalContentAlignment="Left" BorderThickness="0" BorderBrush="Transparent" PopupContent="{Binding}" Foreground="Black"  FontWeight="Bold" VerticalContentAlignment="Center" Margin="0,0,10,0" Background="Transparent" IsRounded="True" Grid.Column="1" Grid.Row="1" DisplayMode="Merged" >
                    <shared:PopupButton.PopupContentTemplate>
                        <DataTemplate>
                            <StackPanel Background="DarkGray" >
                                <Button ToolTip="Cancel" Tag="{Binding}" Style="{DynamicResource GreenGlassButtonStyle}" Margin="2" Height="24"  Width="110" Foreground="White" Content="Cancel" HorizontalAlignment="Right" />
                                <Button ToolTip="Modify" Tag="{Binding}" Style="{DynamicResource RedGlassButtonStyle}" Margin="2" Height="24" Width="110" Foreground="White" Content="Modify" HorizontalAlignment="Right"  />
                                <Button ToolTip="Stop" Tag="{Binding}" Style="{DynamicResource RedGlassButtonStyle}" Margin="2" Height="24" Width="110" Foreground="White" Content="Stop" HorizontalAlignment="Right"  />
                            </StackPanel>
                        </DataTemplate>
                        </shared:PopupButton.PopupContentTemplate>
                </shared:PopupButton>
            </ControlTemplate>

XAML GridView

<telerik:RadGridView RowLoaded="FluidsGridRowLoaded"Grid.Row="1" AutoGenerateColumns="True" ItemsSource="{Binding FluidsDataSource}" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" />

Code

private void FluidsGridRowLoaded(object sender, RowLoadedEventArgs e)
{
    if (!DesignerProperties.GetIsInDesignMode(this))
    {
        if (e.Row.Cells.Count > 0)
            e.Row.Cells[0].Template = Application.Current.Resources["FluidEditorTemplate"] as ControlTemplate;
    }
}

Thanks,

Billy Jacobs



StevenDale
Top achievements
Rank 2
 answered on 05 Apr 2012
2 answers
164 views
I have a form with some fields.  One of the fields is an ordinary TextBox that is bound to a variable of type Decimal.

When I type letters into the field, it's highlighted in red, to indicate that it has failed validation, but the validation error is not added to the form's ValidationSummary, and ValidationSummary.HasErrors remains True.

Am I simply misunderstanding what ValidationSummary is supposed to do?
Jeff
Top achievements
Rank 1
 answered on 05 Apr 2012
17 answers
482 views
I'm getting an application crash when I drag a row from a RadGridView and drop it into an open doc in WordPad.  I don't get a crash when I drop it into an open doc in Notepad, Word 2003, or Excel 2003.  Drag and drop within the application seems to work fine.

Exception:
  • {"Error HRESULT E_FAIL has been returned from a call to a COM component."}
  • -2147467259

Here's the stack trace:
  •    at MS.Win32.UnsafeNativeMethods.DoDragDrop(IDataObject dataObject, IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
  •    at System.Windows.OleServicesContext.OleDoDragDrop(IDataObject dataObject, IOleDropSource dropSource, Int32 allowedEffects, Int32[] finalEffect)
  •    at System.Windows.DragDrop.OleDoDragDrop(DependencyObject dragSource, DataObject dataObject, DragDropEffects allowedEffects)
  •    at System.Windows.DragDrop.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects)
  •    at Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Controls\DragDropManager\DragDropManager.cs:line 1012
Bill
Top achievements
Rank 1
 answered on 05 Apr 2012
4 answers
163 views
We have an application that uses RadGridView.
We use RadGridView collection of objects that have attributes of validation.
There is also a button on the ToolBar that switches on edit mode of objects (editing is disabled by default).
The problem is that when you add a new object that does not pass validation and disable the editing mode, the application crashes with StackOverflowException.
If the button Edit Mode is not on the ToolBar everything works fine.

List the steps to repeat this behavior:
1) Press the Edit Mode (on the toolbar)
2) Add a new blank line (by pressing Ins)
3) Cancel the edit mode by clicking the Edit Mode (on the toolbar)
4) Click on any item on the main window
5) get the exception

If in p.3) you press the the EditMode button not on the toolbar everything will work fine without any exceptions.

UPD Sample project in archive 
Denis
Top achievements
Rank 1
 answered on 05 Apr 2012
0 answers
96 views
Hello,

I'm  having a tough time getting a List box to Drag and Drop onto a RadDataForm

the RadListBox has a different type object bound to the collection than the RadDataForm , however both share a single common field

any examples would be greatly appreciated i have included a snapshot of the application along with the offending issue


Kris
Top achievements
Rank 1
 asked on 05 Apr 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?