Telerik Forums
UI for WPF Forum
1 answer
280 views
I have custom classes and custom styles for RadDiagram, RadDiagramShape, RadDiagramConnection, RadDiagramConnector. Now I have run into a styling issue that requires pro help from you :)

I want my connectors to show their label when either of these two conditions is met:
1) The connector's shape (or any of its children) is hovered by the mouse.
2) Any connection, from any shape, is being dragged.

I started off adding a TextBlock to my connector style, but it seems I cannot properly toggle its visibility. If I set it to "Collapsed", it is never shown. Maybe this approach is all wrong, but still, here it is:

<Style TargetType="chart:MyChartConnector" x:Key="MyChartConnectorStyle" BasedOn="{StaticResource RadDiagramConnectorStyle}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <!-- Auto seems reasonable? -->
    <Setter Property="Width" Value="Auto" />
    <Setter Property="Height" Value="Auto" />
 
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="chart:MyChartConnector">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="MouseStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisplayElement"
                                            Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ActiveStates">
                            <VisualState x:Name="Inactive" />
                            <VisualState x:Name="Active">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0"
                                            Storyboard.TargetName="DisplayElement"
                                            Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid>
                        <Ellipse x:Name="OverElement"
                                 Width="20"
                                 Height="20"
                                 Fill="{TemplateBinding Background}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Stroke="{TemplateBinding BorderBrush}" />
                        <Ellipse x:Name="DisplayElement"
                                 Width="20"
                                 Height="20"
                                 Fill="#40000000"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Stroke="{TemplateBinding BorderBrush}" />
 
                        <!-- This does not work as intented :( -->
                        <TextBlock Text="{TemplateBinding DisplayName}" Visibility="Collapsed">
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type chart:MyChartShape}}, Path=IsMouseOver}" Value="True" >
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Hristo
Telerik team
 answered on 03 Sep 2013
2 answers
136 views
Hello,

I have a radchart and personalized chartlegend. In my chartlegend I have a checkbox and I need to get the color that has given radchart sets. But when I try to know the color, in "aparrence" fields appear all to null, but really if you are painting with a certain color.

<telerik:RadChart x:Name="RadChart1"
                  Grid.Row="1"
                  Grid.Column="1"
                  UseDefaultLayout="False">
    <telerik:RadChart.SamplingSettings>
        <telerik:SamplingSettings SamplingFunction="Average" />
    </telerik:RadChart.SamplingSettings>
 
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="10" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
            <RowDefinition Height="100" />
            <RowDefinition Height="10" />
        </Grid.RowDefinitions>
        <Grid />
        <telerik:ChartLegend x:Name="legendChart"
                             Grid.Row="2"
                             Grid.Column="1"
                             Header=""
                             ItemContainerStyle="{DynamicResource CharLegendStyle}"
                             ItemsPanelOrientation="Horizontal"
                             LegendItemMarkerShape="Circle"
                             UseAutoGeneratedItems="false" />
 
        <telerik:ChartArea x:Name="lineGraphChartArea"
                           Grid.Row="1"
                           Grid.Column="1"
                           HorizontalAlignment="Stretch"
                           VerticalAlignment="Stretch"
                           EnableAnimations="False"
                           LegendName="legendChart">
            <telerik:ChartArea.AxisX>
                <telerik:AxisX Title="Fecha"
                               AutoRange="True"
                               IsDateTime="True"
                               Step="1" />
            </telerik:ChartArea.AxisX>
            <telerik:ChartArea.AxisY>
                <telerik:AxisY Title="CMN"
                               AutoRange="True"
                               ExtendDirection="Up"
                               IsZeroBased="True" />
            </telerik:ChartArea.AxisY>
 
 
        </telerik:ChartArea>
 
    </Grid>
 
 
</telerik:RadChart>


public SeriesMapping GenerateRandomSeries(string nameSerie,int begin)
        {
            SeriesMapping serie1 = new SeriesMapping();
            serie1.ItemsSource = GenerateRandomData(begin);
            serie1.ChartAreaName = "lineGraphChartArea";
            serie1.LegendLabel = nameSerie;
            ItemMapping X = new ItemMapping("Fecha", DataPointMember.XValue);
            ItemMapping Y = new ItemMapping("CMN", DataPointMember.YValue);
            serie1.ItemMappings.Add(X);
            serie1.ItemMappings.Add(Y);
 
            serie1.SeriesDefinition = new SplineSeriesDefinition()
                {
                    
                };
            
             
 
            return serie1;
 
        }
 
public void AddSerieDefinition()
        {
 
 
            RadChart1.SeriesMappings.Add(GenerateRandomSeries("serie1",5));
            RadChart1.SeriesMappings.Add(GenerateRandomSeries("serie2",10));
            RadChart1.SeriesMappings.Add(GenerateRandomSeries("serie3",15));
        }


I try get color and (look attached)


Thank you!
david
Top achievements
Rank 1
 answered on 03 Sep 2013
1 answer
187 views
I am trying to bind a contextual group to the IsActive property using a custom property of a UserControl. The contextual tab should only be shown after the user has selected a port from a dropdown list. I have tried each of the following with no success, but hopefully it gives you an idea of what I'm trying to do.

<telerik:RadRibbonView.ContextualGroups>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource Self}, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding ElementName=_this, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MyRibbon}}, Path=IsPortSelected}"/>
<telerik:RadRibbonContextualGroup x:Name=
"xCOM" IsActive="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=IsPortSelected}"/>
</telerik:RadRibbonView.ContextualGroups>

Where IsPortSelected is the property in MyRibbon:

string _port = "";
public string Port
{
    get { return _port; }
    set
    {
        if (_port == value)
        {
            return;
        }
        _port = value;
    }
}
 
public bool IsPortSelected
{
    get
    {
        if (String.IsNullOrEmpty(_port))
        {
            return false;
        } else if (_port.Equals("Port")) {
            return false;
        }
        return true;
    }
    set { }
}

Is there something wrong with my binding statement? Or do I need to do something else in the code behind, such as implementing a PropertyChangedEventHandler (which I have tried with no success as well)?
Pavel R. Pavlov
Telerik team
 answered on 03 Sep 2013
1 answer
96 views
Hello,

I got a RadGridView Inside a RadWindow, I'm trying to paste in this RadGridview some data copied from Excel, it works fine if i click over the left top corner of the Radgridview, but if i open the RadWindow and attempt to paste right away, it just doesnt work, the paste event doesnt get fired. the globlal functionality is:


1. Press some button and open the RadWindow with my empty RadGridView Inside
2. Without clicking anywhere,  Press Ctrl + V and paste inside the RadGridView all the data that i have in the clipboard
3. that's it

I tried to set the focus to the RadGridView, but it doesnt seems to work.

Thanks.

Maya
Telerik team
 answered on 03 Sep 2013
4 answers
385 views
Hi,

any easy way to replace the selected text with new style ?
Sopan
Top achievements
Rank 1
 answered on 03 Sep 2013
5 answers
405 views
hi,
Can we have grid lines that is shown on the graph as dotted lines instead of dashed lines?
<telerik:RadCartesianChart.Grid>
                    <telerik:CartesianChartGrid>
                        <telerik:CartesianChartGrid.Style>
                            <Style TargetType="telerik:CartesianChartGrid">
                                <Setter Property="MajorXLineDashArray" Value="10,5"/>
                                <Setter Property="MajorYLineDashArray" Value="10,5"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=DisplayGridLines}" Value="1">
                                        <Setter Property="MajorLinesVisibility" Value="X"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=DisplayGridLines}" Value="2">
                                        <Setter Property="MajorLinesVisibility" Value="Y"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=DisplayGridLines}" Value="3">
                                        <Setter Property="MajorLinesVisibility" Value="XY"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </telerik:CartesianChartGrid.Style>

                        <telerik:CartesianChartGrid.MajorXLineStyle>
                            <Style TargetType="Line">
                                <Setter Property="Stroke" Value="Gray"/>
                            </Style>
                        </telerik:CartesianChartGrid.MajorXLineStyle>

                        <telerik:CartesianChartGrid.MajorYLineStyle>
                            <Style TargetType="Line">
                                <Setter Property="Stroke" Value="Gray"/>
                            </Style>
                        </telerik:CartesianChartGrid.MajorYLineStyle>
                    </telerik:CartesianChartGrid>
                </telerik:RadCartesianChart.Grid>

I have 10 points being shown on the graph. so the grid lines appear for all the 10 points. Can we have it just five and increase it if needed?
Please reply as soon as possible.

Petar Marchev
Telerik team
 answered on 02 Sep 2013
1 answer
123 views

When a property return type is ArraySegment<T> and properties are auto-generated, an exception is thrown and the control is not displayed.

My example specifically:

public class TestClass
{
    private readonly ArraySegment<string> _strings;
    public IReadOnlyList<string> Strings
    {
        get { return this._strings; }
    }
}
Maya
Telerik team
 answered on 02 Sep 2013
0 answers
102 views
Hi is there any possibility to pin RadPane from code behind? for example I have button inside radpane and after pressing the button I want to pin my RadPane

I am sorry for post I have my answer it is isPinned = false; (I had true value so It doesnt worked :D) please delete this topic :) thank you :)
Jiri
Top achievements
Rank 1
 asked on 02 Sep 2013
3 answers
222 views
In our project we want to load settings. Because of the origin of this settings structure these are very generic, exposed via wcf etc. So when we load them in our viewmodel they have the type Object. Also they consist of the real type information so we can convert them to the corresponding type. So far so good. 

When we load them in a gridview we would like to have different controls, for the different types. A Boolean should be a togglebutton, a int a numeric updown control and a string a regular textbox. For this approach we use Template selectors, but we also need to convert the types of the objects as described above. Therefore we use converters so the controls accepting the correct values and types. Until this point everything works great. We the problem arises when you scroll down in the grid. I guess you did some optimization. Therefore the templates and converters are evaluated when scrolling down. But in a different order then on initial loading. When the grid load for the first time, first the template is selected and then the converter. But when scrolling down, this order changes. To me that's a bit strange, because how can the converter be determined is there is no template. You will find sample code below. Only in our application there are binding errors showing up in the output window, in this example not. But the problem is still the same. Can we work around this issue, or need you guys to update this?

MainWindow:
<Grid>
        <Grid.Resources>
            <local:BooleanConverter x:Key="BooleanConverter" />
            <local:InvBooleanConverter x:Key="InvBooleanConverter" />
            <local:StringToIntConverter x:Key="StringToIntConverter" />
            <local:StringToDblConverter x:Key="StringToDblConverter" />
            <local:SettingValueTemplateSelector x:Key="SettingValueTemplateSelector" >
                <local:SettingValueTemplateSelector.BooleanTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <telerik:RadRadioButton IsChecked="{Binding Path=Value}">
                                <TextBlock Text="Enabled"/>
                            </telerik:RadRadioButton>
                            <telerik:RadRadioButton IsChecked="{Binding Path=Value}">
                                <TextBlock Text="Disabled"/>
                            </telerik:RadRadioButton>
                        </StackPanel>
                    </DataTemplate>
                </local:SettingValueTemplateSelector.BooleanTemplate>
                <local:SettingValueTemplateSelector.IntTemplate>
                    <DataTemplate>
                        <telerik:RadNumericUpDown Value="{Binding Path=Value, Converter={StaticResource StringToIntConverter}}" NumberDecimalDigits="0"/>
                    </DataTemplate>
                </local:SettingValueTemplateSelector.IntTemplate>
                <local:SettingValueTemplateSelector.DoubleTemplate>
                    <DataTemplate>
                        <telerik:RadNumericUpDown Value="{Binding Path=Value,Converter={StaticResource StringToDblConverter}}" />
                    </DataTemplate>
                </local:SettingValueTemplateSelector.DoubleTemplate>
                <local:SettingValueTemplateSelector.StringTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Value, Mode=TwoWay}" />
                    </DataTemplate>
                </local:SettingValueTemplateSelector.StringTemplate>
            </local:SettingValueTemplateSelector>
 
        </Grid.Resources>
        <telerik:RadGridView x:Name="RadGridView" GroupRenderMode="Flat"
                             RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False"
                             ItemsSource="{Binding ElementName=Window1, Path=List}"
                             IsReadOnly="false"
                             ScrollMode="Deferred"
                             AutoExpandGroups="True"
                             AutoGenerateColumns="false" Margin="0,2,0,-2">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn
                    Header="Value"
                    IsGroupable="True"                   
                    DataMemberBinding="{Binding Value}" 
                    CellTemplateSelector="{StaticResource SettingValueTemplateSelector}"
                    Background="LightGray">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    Header="ValueType"
                    IsGroupable="True"                   
                    DataMemberBinding="{Binding ValueType}"                   
                    Background="LightGray">
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
Template selector:
public class SettingValueTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is DataObjecten)
            {
                DataObjecten model = item as DataObjecten;
 
                if (model.ValueType == typeof(int))
                    return this.IntTemplate;
                else if (model.ValueType == typeof(String))
                    return this.StringTemplate;
                else if (model.ValueType == typeof(double))
                    return this.DoubleTemplate;
                else if (model.ValueType == typeof(bool))
                    return this.BooleanTemplate;
                else
                    return null;
            }
            return null;
        }
}

One of the converters (basic):
public class StringToIntConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        int retValue=0;
        if (int.TryParse(value.ToString(), out retValue))
        {
            return retValue;
        }
        else
            return 0;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
          throw new NotSupportedException("Do not use this converter for objects other than boolean");
    }
}

Model:
public class DataObject
  {
      public object Value { get; set; }
      public Type ValueType { get; set; }
  }
 
          List.Add(new DataObject() { Value = "8", ValueType = typeof(int) });
          List.Add(new DataObject() { Value = "8", ValueType = typeof(double) });
          List.Add(new DataObject() { Value = "8gf", ValueType = typeof(string) });
          List.Add(new DataObject() { Value = 454365, ValueType = typeof(int) });
          List.Add(new DataObject() { Value = false, ValueType = typeof(bool) });

Nedyalko Nikolov
Telerik team
 answered on 02 Sep 2013
1 answer
207 views
Hi,

I'm having troubles with the onMouseEnter and onMouseLeave for the RadTreeViewItems.

Each time the mouse is over an item I need to show an image ("Gear")  beside this RadTreeviewItem. I'm showing this image with the onMouseEnter event and i'm hiding it with the onMouseLeave event. The problem is when i select a RadTreeViewItem that is inside another RadTreeViewItem. It shows its "Gear" and also its father "Gear".

The event is fired by the item that got the mouseOver and by all its fathers. the event should be fired only by the item with the mouse over.

can you please advise me?

thanks



Pavel R. Pavlov
Telerik team
 answered on 02 Sep 2013
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?