Telerik Forums
UI for WPF Forum
2 answers
157 views

Hi, I has a diagram, and use ExportToImage method to export to png, but the png file is 0KB, and can't diaplay in windows photo viewer, why?

The code is:

namespace OpenDiagramdemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public RadDiagram diagram;
        public MainWindow()
        {
            InitializeComponent();
            diagram = new RadDiagram();
            //the shapes up to 500, display is slow
            for(int i = 0; i < 1000; i++)
            {
                RadDiagramShape s = new RadDiagramShape();
                s.Stroke = Brushes.Red;
                s.BorderBrush = Brushes.Red;
                s.StrokeThickness = 2;
                s.IsEditable = false;
                s.Foreground = Brushes.Transparent;
                s.Background = Brushes.Transparent;
                s.Width = 113;
                s.Height = 76;
                s.X = i;
                s.Y = i;
                s.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape);//"M0.5,0.5L111.5,0.5 111.5,74.5 0.5,74.5z"
                diagram.AddShape(s);
            }
        }
       
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            FileStream fs = File.Open("D:\\\\tt.png", FileMode.Create);
            this.diagram.ExportToImage(fs);
            fs.Close();
        }
    }
}

When run this program, make a diagram And draw a menu in xaml. Define the menu click event MenuItem_Click. Click menu and see the result described above.

Thanks!

Jonathan
Top achievements
Rank 1
 answered on 16 Jun 2017
2 answers
166 views

Hi, I have problem with RadialGauge. When I set BarIndicator value = 100 and it disappear. Please help me!

 

<telerik:RadRadialGauge x:Name="radGauge">
            <telerik:RadialScale x:Name="radialScale"
                                 IsInteractive="True"
                                 RangeLocation="OverOutside"
                                 LabelRotationMode="None"
                                 Radius="0.9"
                                 StartAngle="270"
                                 SweepAngle="360"
                                 Max="100"
                                 MinorTickBackground="Transparent"
                                 MiddleTickBackground="Transparent"
                                 MajorTickBackground="Transparent"
                                 ShowLastLabel="False"
                                 LabelTemplate="{StaticResource CustomRadialLabelTemplate}">
                <telerik:RadialScale.Indicators>
                    <telerik:BarIndicator
                        x:Name="bar"
                        StartWidth="0.15"
                        EndWidth="0.15"
                        EmptyFill="LightGray"
                        telerik:ScaleObject.Location="OverCenter"/>
 
                </telerik:RadialScale.Indicators>
            </telerik:RadialScale>
        </telerik:RadRadialGauge>
TuDN
Top achievements
Rank 1
 answered on 16 Jun 2017
1 answer
115 views

Hey community,

the row redorder sample doesn't work within a RadLayoutControl. It looks like as if the RadLayoutControl would intercept the DragEvent, so the  GiveFeedbackEventArgs is not called within the RowReorderBehavior.

Can you provide me a sample or give me a hint please.

 

Kind regards,

Lars

Lars D.
Top achievements
Rank 1
 answered on 16 Jun 2017
7 answers
2.3K+ views

I am using a radGridView in Master/Detail scenario using MVVM; the selected item is displayed in a custom form that allows editing.
The Form's DataContext and the Grid's SelectedItem are bound to a property in the ViewModel.
When the Grid's selection is changing, I check if the Form is in Edit mode, and if so I cancel the selection change.

This works as it should.

However, there are some circumstances where the Grid's ItemSource (CollectionViewSource) changes and the Grid looses track of the SelectedItem. I can throw NotifyPropertyChanged on the property, and the grid doesn't notice. When the grid is in this state and the user selects a row, the logic in SelectionChanging does not prevent the SelectedItem from changing. In fact it sets the SelectedItem to null, rather than the attempted selection row.

I really need to prevent the SelectedItem from changing (or becoming null) while the item is being edited. I think the best way would be to prevent the grid from getting into this strange state.

How can I force the grid to realize its SelectedItem, if NotifyPropertyChanged is not doing the trick?

Does the grid loose its SelectedItem binding when the Itemssource updates?

 

 

XAML:
    <telerik:RadGridView Grid.RowSpan="2" ShowGroupPanel="False" AutoGenerateColumns="False" IsFilteringAllowed="False"
        ItemsSource="{Binding Zones.View}"  x:Name="grd_ZoneBins" IsReadOnly="True" EditTriggers="None"
        SelectedItem="{Binding SelectedZone, Mode=TwoWay}"
        SelectionChanging="grd_ZoneBins_SelectionChanging" >
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="Zone" DataMemberBinding="{Binding Name}" Width="*" />
            <telerik:GridViewDataColumn Header="Active" DataMemberBinding="{Binding IsActive}" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

CodeBehind:
    private void grd_ZoneBins_SelectionChanging(object sender, Telerik.Windows.Controls.SelectionChangingEventArgs e)
    {
        if (EditableWorkSpace_ZoneBins.Mode == EditMode.Editable) //this is a custom control
            e.Cancel = true;
    }

ViewModel:
    //Properties
    private List<Part_Zone> _zones;
    public CollectionViewSource Zones { get; set; }
    private Part_Zone m_SelectedZone;
    public Part_Zone SelectedZone
    {
        get { return m_SelectedZone; }
        set { m_SelectedZone = value; NotifyPropertyChanged("SelectedZone");}
    }

    public Model() //constructor
    {
        Zones = new CollectionViewSource();
        Zones.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
        LoadData();
    }

    private void LoadData()
    {
        _zones = GetZones();
        Zones.Source = _zones;
        SelectedZone = Zones.View.CurrentItem as Part_Zone; //first item
    }

    public void Refresh()
    {
        LoadData();
        //at this point the grid doesn't seem aware that the SelectedZone is its SelectedItem
    }

    public void StartEdit()
    {
        View.EditableWorkSpace_ZoneBins.Mode = EditMode.Editable;
        NotifyPropertyChanged("SelectedZone"); // just in case
    }

Steps to reproduce:
1) load data
2) select item in grid
3) refresh data - grid looses selectedItem. SelectedZone is not null.
4) start edit
5) change selection - gets canceled due to Edit mode
6) SelectedZone is set to null.


Stefan
Telerik team
 answered on 16 Jun 2017
6 answers
377 views

Dear Admin

I just use RadGridView control for excel content shown in MVVM pattern, and before amount excel data, I do not know exact columns and rows shown in RadGridView, so I use datatable as my datasource binded to RadGridView's ItemsSource. But actually I would like to change some columns  datatype from string to Image, I try to add AutoGeneratingColumn event and set CellTemplate for specified columns, and the result was that there was no response after loading and only shut-down whole window.

so in this case is there any other workaround to archive similar case? any ideas I do really appreciate.

Yoan
Telerik team
 answered on 15 Jun 2017
2 answers
1.2K+ views
What is the best event to detect when a new row has been added via binding?

For instance I have a WPF (form application) with a grid bound to a ObservableCollection<foo> class. When I add a new object to the collection, it is added to grid automatically.

I want to detect that a new row has been added by the grid and put the select a cell and put it in edit mode.

I'm currently accomplishing this task using the RowLoaded event and it is working. However, once there are enough rows added that cause the grid to have a vertical scroll bar AND the user then scrolls up in the grid then the RowLoaded event fires again ... even though the row already exists. So I've had to had special code to really identify in RowLoaded when the event fired from a true add to the collection.

I would like to know if there is another event to use and I've inspected several of them. I thought DataLoaded would work and it fires, however I cannot figure out a way to make a particular cell selected and placed in mode via this event. The code that I'm using that is working in RowLoaded event is this
if (e.DataElement != null)
{
    ((GridViewCell)e.Row.Cells[7]).BeginEdit();
}

Thanks ... Chad
Ujwal
Top achievements
Rank 1
 answered on 15 Jun 2017
1 answer
232 views
How to hide plus sign from RadGridView row, if no childrows exist ?
Lance | Senior Manager Technical Support
Telerik team
 answered on 14 Jun 2017
1 answer
648 views

Hello,

I have a combobox on which i am trying to modify the default tooltip style.This is applicable when I am hovering on individual combobox items and I should get the tooltip. Right now for tooltip , we are showing up the text value. But I want to override this deafult style and show the description instead. (Note that description is a user defined property).

The code snippet right now is:

<Style.Resources>
            <Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource ComboBoxItemStyle}">
                <!--<Setter Property="ToolTip" Value="{Binding ToolTipDescription, Mode=TwoWay}"/>-->
                <Setter Property="ToolTip" Value="{Binding}"/>
            </Style>
        </Style.Resources>

 

Here while setting the property "tooltip" <Setter Property="ToolTip" Value="{Binding ToolTipDescription, Mode=TwoWay}"/>. I tried doing something like this. Here I exposed a public property from my class which is holding the description value that I need to show when i am hovering on the individual item. But the binding is not working.

 

I need your input to proceed further.

Dinko | Tech Support Engineer
Telerik team
 answered on 14 Jun 2017
2 answers
174 views

A pair of RadTimePickers I have for selecting the beginning and end of a shift are displaying the timeview incorrectly after being enabled and having the starttime and endtime values set. They both show every slot from 12AM to 11:45PM, but starting with 12AM selecting a slot displays the value that SHOULD be seen, 8:30AM in this case, and continues for each subsequent slot in the same manner until the endtime slot, whose correct value is 5:15PM at the 8:45AM slot on the selection view. When the binding event is called a second time, the timeviews for both RTPs are correctly shown, going from 8:30AM to 5:15PM. HTML markup of the RTPs in question as follows, as well as the code-behind for the binding event.

//HTML//
<telerik:RadTimePicker ID="tpStartTime" runat="server" EnableTyping="false" TimeView-Columns="4" TimeView-Interval="00:15:00" Enabled="false"></telerik:RadTimePicker>
<telerik:RadTimePicker ID="tpEndTime" runat="server" EnableTyping="false" TimeView-Columns="4" TimeView-Interval="00:15:00" Enabled="false"></telerik:RadTimePicker>
 
//C#//
protected void dpOriginalDate_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        DateTime[] shift = getShift((DateTime)dpOriginalDate.SelectedDate);
        tpStartTime.Enabled = tpEndTime.Enabled = true;
        tpStartTime.TimeView.StartTime = shift[0].TimeOfDay;
        tpStartTime.TimeView.EndTime = shift[1].TimeOfDay;
        tpEndTime.TimeView.StartTime = shift[0].AddMinutes(15).TimeOfDay;
        tpEndTime.TimeView.EndTime = shift[1].AddMinutes(15).TimeOfDay;
    }

Page_Load contains Page.DataBind(); which appears to be the cause. Do I have to do without it or is there a workaround?

 

 

Jackie
Top achievements
Rank 1
 answered on 14 Jun 2017
8 answers
333 views
Hi, I need to perform coded UI tests on a WPF application with Telerik controls. I installed Telerik.VisualStudio.TestTools.UITest.Extension.ExtensionsCore.dll following the instructions posted here.

However, I am not able to use the GetProperty method for control specific properties, i.e. "ItemState" on a RadTileViewItem. I am able to find the item and for example draw a highlight around it, but trying to get it's TileState results in a NotSupportedException:

GetProperty of "TileState" is not supported on control type: Custom

What seems strange: If I start the coded ui test builder and pull the crosshair over the TileViewItem, I can see it's TileState property and the correct value. Only the test playback is not able to retrieve it.

Am I missing something important to make the uitest extension working?

Ivan Ivanov
Telerik team
 answered on 14 Jun 2017
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
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
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
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?