public class Table : RadGridView
{
public Table()
{
EventManager.RegisterClassHandler(typeof(GridViewCellBase), LoadedEvent, new RoutedEventHandler(OnGridViewCellLoaded), true);
}
private static void OnGridViewCellLoaded(object sender, RoutedEventArgs e)
{
var cell = sender as GridViewCellBase;
if (cell != null)
{
var dataType = cell.DataColumn.DataType;
if (dataType == typeof(int) || dataType == typeof(double) || dataType == typeof(float) || dataType == typeof(decimal))
{
cell.SetValue(Table.NumberColumnProperty, true);
}
}
}
public static bool GetNumberColumn(DependencyObject obj)
{
return (bool)obj.GetValue(NumberColumnProperty);
}
public static void SetNumberColumn(DependencyObject obj, bool value)
{
obj.SetValue(NumberColumnProperty, value);
}
public static readonly DependencyProperty NumberColumnProperty =
DependencyProperty.RegisterAttached("NumberColumn", typeof(bool), typeof(Table),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));
}
I would like to add some static text to the Comparative Measure element. I have re-templated the bullet graph, but my attempts to add the text does not seem to work. I would like the text to float at the top right of the line. Is this possible?
Here is my style template:
<
Style
x:Key
=
"RadHorizontalBulletGraphStyle"
TargetType
=
"telerik:RadHorizontalBulletGraph"
>
<
Setter
Property
=
"ComparativeMeasureThickness"
Value
=
"1"
/>
<
Setter
Property
=
"FontSize"
Value
=
"10"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:RadHorizontalBulletGraph"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"5*"
/>
<
RowDefinition
Height
=
"5*"
/>
</
Grid.RowDefinitions
>
<
Border
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
Background
=
"White"
Grid.Row
=
"0"
>
<
Grid
>
<
Grid
>
<
Grid.Resources
>
<
Style
TargetType
=
"telerik:BarItem"
>
<
Setter
Property
=
"LengthPercent"
Value
=
"1"
/>
</
Style
>
</
Grid.Resources
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"5*"
/>
<
RowDefinition
Height
=
"5*"
/>
</
Grid.RowDefinitions
>
<
telerik:FeaturedMeasurePresenter
Grid.Row
=
"0"
Content
=
"{TemplateBinding FeaturedMeasureInternal}"
Margin
=
"0,5"
/>
<
telerik:FeaturedMeasurePresenter
Grid.Row
=
"1"
Content
=
"{TemplateBinding ProjectedMeasureInternal}"
Margin
=
"0,5"
/>
</
Grid
>
<
StackPanel
HorizontalAlignment
=
"Stretch"
>
<
telerik:ComparativeMeasuresContainer
ChildrenSource
=
"{TemplateBinding MergedComparativeMeasures}"
Range
=
"{TemplateBinding Range}"
Margin
=
"-15"
/>
</
StackPanel
>
</
Grid
>
</
Border
>
<
telerik:QuantitativeScaleContainer
Grid.Row
=
"1"
TextFormatString
=
"{TemplateBinding TextFormatString}"
Visibility
=
"{TemplateBinding QuantitativeScaleVisibility}"
Opacity
=
"0.5"
RenderTransformOrigin
=
"0.5,0.5"
Range
=
"{TemplateBinding Range}"
>
<
telerik:QuantitativeScaleContainer.RenderTransform
>
<
TranslateTransform
Y
=
"5"
/>
</
telerik:QuantitativeScaleContainer.RenderTransform
>
</
telerik:QuantitativeScaleContainer
>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
<
SolidColorBrush
x:Key
=
"ActualBrush"
Color
=
"Green"
/>
<
SolidColorBrush
x:Key
=
"TargetBrush"
Color
=
"Red"
/>
And here is my control definition:
<
telerik:RadHorizontalBulletGraph
TextFormatString
=
"${0}"
ProjectedValue
=
"150"
FeaturedMeasure
=
"200"
ComparativeMeasure
=
"175"
Height
=
"100"
Style
=
"{StaticResource RadHorizontalBulletGraphStyle}"
FeaturedMeasureBrush
=
"{StaticResource ActualBrush}"
ProjectedValueBrush
=
"{StaticResource TargetBrush}"
Step
=
"200"
/>
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d) at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks) at System.Windows.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at System.Windows.Media.Visual..ctor(ResourceType resourceType) at System.Windows.FrameworkElement..ctor() at System.Windows.Controls.Control..ctor() at System.Windows.Controls.ContentControl..ctor() at Telerik.Windows.Controls.RadChart..ctor() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\Charting\Chart\RadChart.cs:line 252 Telrik doesn't install on the machine. We use dll from library. What does this path ment?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Persistence;
using Telerik.Windows.Persistence.Storage;
namespace WpfApplication_Docking
{
static public class PersistenceStorage
{
#region Public methods.
/// <summary>
/// Load/Save all controls that contain "telerik:PersistenceManager.StorageId="..."
/// The file location is "$APPDATA\IsolatedStorage\..."
/// </summary>
/// <param name="pPersistenceAction">Load/Save</param>
/// <param name="pErrorMessage">Error received during the persistence.</param>
/// <returns>true if successfull otherwise false</returns>
static public bool Persist(PersistenceAction pPersistenceAction, out string pErrorMessage)
{
pErrorMessage = string.Empty;
PersistenceManager manager = new PersistenceManager();
//manager.PropertyPersisting += new Telerik.Windows.Persistence.Events.PropertyPersistingEventHandler(manager_PropertyPersisting);
IsolatedStorageProvider storage = new IsolatedStorageProvider(manager);
try
{
try
{
if (pPersistenceAction == PersistenceAction.Load)
{
storage.LoadFromStorage();
}
else if (pPersistenceAction == PersistenceAction.Save)
{
storage.SaveToStorage();
}
return true;
}
catch (Exception ex)
{
pErrorMessage = ex.Message;
return false;
}
}
finally
{
//manager.PropertyPersisting += new Telerik.Windows.Persistence.Events.PropertyPersistingEventHandler(manager_PropertyPersisting);
}
}
/// <summary>
/// Event triggered when the stream persistence didn't worked.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void manager_PersistenceError(object sender, Telerik.Windows.Persistence.Events.PersistenceErrorEventArgs e)
{
mErrorMessage = e.Exception.Message;
mResult = false;
throw new NotImplementedException();
}
/// <summary>
/// This event is used to prevent any BroderBrush to have a transparent color when we persist an object.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void manager_PropertyPersisting(object sender, Telerik.Windows.Persistence.Events.PersistingPropertyEventArgs e)
{
//Not needed since version 2011.3.1116.35 of Telerik
//if (e.Name == "BorderBrush")
// e.Cancel = true;
}
#endregion
#region Enumerators.
public enum PersistenceAction { Load, Save }
#endregion
#region Private declarations.
static private string mErrorMessage;
static private bool mResult;
#endregion
}
}