Telerik Forums
UI for WPF Forum
2 answers
135 views

I have a grid like this:

<telerik:RadGridView x:Name="DataG"ItemsSource="{Binding CamposUsu}"SelectedItem="{Binding Selected}"CanUserReorderColumns="True"CanUserResizeColumns="True"CanUserSortColumns="False"SelectionUnity="FullRow"IsReadyOnly="True"AutoGenerateColumns="False"Loaded="DataG_Loaded" />

 

In the .cs file the method DataG_Loaded:

private void DataG_Loaded(object sender, RoutedEventesArgs e)

{

DataTemplate labelTemplate = new DataTemplate();

FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));

label.SetValue(Label.ContentProperty, "Unlimited");

labelTemplate.VisualTree = label;

labelTemplate.Seal();this.DataG.Columns[7].CellTemplate = labelTemplate;

//this column 7 is a column called "Vl." with double values

}

Well, when I comment the method DataG_Loaded, my grid is fulfilled correctly with the objects I created on my viewmodel. When I uncomment the method, the column "Vl." that had values like "93.5", "108.9"... is all fulfilled with the value "Unlimited".
This was already expected. I want only the cells that the value is > 100.0 to turn to the string "Unlimited".

Is there any way of doing this?

Martin
Telerik team
 answered on 22 Oct 2015
1 answer
122 views

Hi,

is it possible to stretch the labels of an categorical axis? I want to create an axis like shown in the goal.jpg

I tried the following code to recived the wished layout:

<telerik:CategoricalAxis TickThickness="0" GapLength="0.1">
  <telerik:CategoricalAxis.LabelTemplate>
    <DataTemplate>
      <StackPanel HorizontalAlignment="Stretch">
        <Border BorderBrush="Black" BorderThickness="1,1,1,0">
          <TextBlock Text="{Binding}"/>
        </Border>
        <Border BorderBrush="Black" BorderThickness="1">
          <TextBlock Text="{Binding Text2}"/>
        </Border>
      </StackPanel>
    </DataTemplate>
  </telerik:CategoricalAxis.LabelTemplate>
</telerik:CategoricalAxis>

But the label does not stretched it still fit ti it contents like shown in StretchedLabelResult.jpg

 Does anyone have an idea how to recive the wished layout?

Dinko | Tech Support Engineer
Telerik team
 answered on 22 Oct 2015
1 answer
150 views

I have a single view with a number of different graphs, all of which have the same x-axis data based on dates.

At present I have the zoom behaviour syncing between the graphs but I would also like to have a trackball behaviour shared between them, is this possible? Or is there ​any way I could reproduce the effect of a trackball line?

Martin Ivanov
Telerik team
 answered on 22 Oct 2015
1 answer
60 views

Hi,

I have a question about GridView group sorting problem.

If I have some data like this:

Group_Name | Group_Order

T_group         |        1

T_group         |        1​

M_group        |        3

M_group        |        3

M_group        |        3​​

J_group         |         2

J_group         |         2 

I want to GridView grouping by "Group_name" but the group order column is "Group_Order".

 

Do you have some good idea?

Thank you

 

 

 

Maya
Telerik team
 answered on 22 Oct 2015
1 answer
184 views

Hello,

Currently I am looking into using the Telerik Diagram library for a new application. Users have to be able to load a background image and then draw (and modify) areas of interest on top of this map (using the standard shapes). On top of that a the 'track / path' of a person has to be drawn / plotted (see the attached image). This drawing / plotting has to be 'live / animated' (e.g. the position of the person changes and this has to be visualized in real-time). Do you have any hints / tips on how to achieve this? What I would like is to have some kind of drawing canvas which has the same size as the 'background image shape' but anything drawn here should be displayed 'over' the other placed shapes. This canvas should also respond to zooming in/out of the diagram.

Kind regards,

Douwe

Petar Mladenov
Telerik team
 answered on 22 Oct 2015
5 answers
338 views

For now, RadRichTextBox does not support dragging or pasting files. So I override the dragevent.

public class UserFile
    {
        public string name;
        public string absoluteAddress;
        public string image;
    }
 
    public class DragableRichTextBox : RadRichTextBox
    {
        public static readonly DependencyProperty UserFilesProperty;
        static int dirCount;
        static DragableRichTextBox()
        {
            FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(new List<UserFile>(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault);
            UserFilesProperty = DependencyProperty.Register("UserFiles", typeof(List<UserFile>), typeof(RadRichTextBox), metadata);
            dirCount = 0;
        }
 
 
        public List<UserFile> UserFiles
        {
            get
            {
                userFiles.Clear();
                XamlFormatProvider provider = new XamlFormatProvider();
                XmlDocument xmlDocument = new XmlDocument();
                string data = provider.Export(this.Document);
                xmlDocument.LoadXml(data);
                scanFileAndAddIamge(xmlDocument.FirstChild);
                SetValue(UserFilesProperty, userFiles);
                return (List<UserFile>)GetValue(UserFilesProperty);
            }
            set { SetValue(UserFilesProperty, value); }
        }
        List<UserFile> userFiles;
        public string SaveDirectory;
        public DragableRichTextBox()
        {
            this.AllowDrop = true;
            this.AddHandler(RichTextBox.DropEvent, new DragEventHandler(dropIn), true);
            this.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(dropOver), true);
            userFiles = new List<UserFile>();
            string basePath = @"C:\123\temp";
            checkPath(basePath);
            for (int i = dirCount; i < 1000; ++i)
            {
                if (checkPath(basePath + @"\" + i))
                {
                    SaveDirectory = basePath + @"\" + i;
                    dirCount = i;
                    break;
                }
            }
        }
 
        bool checkPath(string path)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                return true;
            }
            else if(dirCount == 0)
            {
                Directory.Delete(path, true);
            }
            return false;
        }
 
        private void dropIn(object obj, DragEventArgs de)
        {
            if (de.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])de.Data.GetData(DataFormats.FileDrop);
 
                foreach (string file in files)
                {
                    UserFile f = new UserFile();
                    System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                    image.Source = GetIcon(file);
                    image.Height = image.Source.Height;
                    image.Width = image.Source.Width;
 
                    PngBitmapEncoder pictureEncoder = new PngBitmapEncoder();
                    pictureEncoder.Frames.Add(BitmapFrame.Create((BitmapSource)image.Source));
                    FileStream fs = new FileStream(String.Format(SaveDirectory + "/{0}.png", userFiles.Count), FileMode.OpenOrCreate, FileAccess.Write);
                    pictureEncoder.Save(fs);
                    fs.Close();
 
                    string path = String.Format(SaveDirectory + "/{0}.png", userFiles.Count);
                    f.image = path;
                    Uri uri = new Uri(path);
                    BitmapImage image1 = new BitmapImage(uri);
                    image.Source = image1;
 
                    StackPanel stk = new StackPanel();
                    stk.Children.Add(image);
                    Telerik.Windows.Controls.Label l = new Telerik.Windows.Controls.Label();
                    for (int i = file.Length - 1; i >= 0; --i)
                    {
                        if (file[i] == '\\')
                        {
                            l.Content = file.Remove(0, i + 1);
                            break;
                        }
                    }
                    Telerik.Windows.Controls.Label l1 = new Telerik.Windows.Controls.Label();
                    l1.Content = file;
                    l1.Visibility = Visibility.Collapsed;
                    stk.Children.Add(l);
                    stk.Children.Add(l1);
                    f.name = l.Content.ToString();
                    f.absoluteAddress = l1.Content.ToString();
                    userFiles.Add(f);
                    Section section = new Section();
                    Paragraph paragraph = new Paragraph();
                    InlineUIContainer container = new InlineUIContainer();
                    container.UiElement = stk;
                    container.Height = 25 + image.Height;
                    double x = l.Content.ToString().Length;
                    container.Width = x * 6.5 > image.Width ? x * 6.5 : image.Width;
                    paragraph.Inlines.Add(container);
                    section.Blocks.Add(paragraph);
                    this.Document.Sections.Add(section);
 
                    RecreateUI();
                    container.Width = stk.ActualWidth;
                }
            }
            RecreateUI();
        }
 
        private void dropOver(object obj, DragEventArgs de)
        {
            if (de.Data.GetDataPresent(DataFormats.FileDrop))
            {
                de.Effects = DragDropEffects.Copy;
            }
            else if (de.Data.GetDataPresent(DataFormats.Text) | de.Data.GetDataPresent(DataFormats.Bitmap) | de.Data.GetDataPresent(DataFormats.CommaSeparatedValue) | de.Data.GetDataPresent(DataFormats.Dib) | de.Data.GetDataPresent(DataFormats.Dif) | de.Data.GetDataPresent(DataFormats.EnhancedMetafile) | de.Data.GetDataPresent(DataFormats.FileDrop))
            {
                de.Effects = DragDropEffects.Scroll;
            }
            else
            {
                de.Effects = DragDropEffects.None;
            }
        }
 
        private ImageSource GetIcon(string fileName)
        {
            Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(fileName);
            return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                        icon.Handle,
                        new Int32Rect(0, 0, icon.Width, icon.Height),
                        BitmapSizeOptions.FromEmptyOptions());
        }
 
        private void RecreateUI()
        {
            if (this.ActiveEditorPresenter != null)
            {
                this.ActiveEditorPresenter.RecreateUI();
                this.UpdateEditorLayout();
            }
        }
 
        private void scanFileAndAddIamge(XmlNode node)
        {
            if (node.ChildNodes.Count == 0)
                return;
            foreach (XmlNode xn in node.ChildNodes)
            {
                if (xn.Name == "av:StackPanel")
                {
                    UserFile f = new UserFile();
                    foreach (XmlNode xn1 in xn.ChildNodes)
                    {
 
                        if (xn1.Name == "Label")
                        {
                            foreach (XmlAttribute attribute in xn1.Attributes)
                            {
                                if (attribute.Name == "Visibility" && attribute.Value == "Collapsed")
                                {
                                    f.absoluteAddress = xn1.InnerText;
                                }
                            }
                            if (xn1.Attributes.Count == 0)
                                f.name = xn1.InnerText;
                        }
                        if (xn1.Name == "av:Image")
                        {
                            foreach (XmlAttribute attribute in xn1.Attributes)
                            {
                                if (attribute.Name == "Source")
                                {
                                    for (int i = attribute.Value.Length - 1; i >= 0; --i)
                                    {
                                        if (attribute.Value[i] == '/')
                                        {
                                            attribute.Value = attribute.Value.Remove(0, i);
                                            break;
                                        }
                                    }
                                    attribute.Value = SaveDirectory + "/" + attribute.Value;
                                    f.image = attribute.Value;
                                    int kk = 11;
                                    kk++;
                                    kk++;
                                }
                            }
                        }
                    }
                    userFiles.Add(f);
                }
                else
                {
                    scanFileAndAddIamge(xn);
                }
            }
        }
    }

 I can drag files now, but the files alway insert in the end of the RadDoucument. I don't know how to get the paragragh or section that my mosue point.

Please help me.

yi
Top achievements
Rank 1
 answered on 22 Oct 2015
5 answers
805 views
Hello, 
Can I put the property read-only only for a single cell in a row and not to the entire column?

I want to change this value depending on the remaining cells in row.

Thanks.
Ganapathi
Top achievements
Rank 1
 answered on 21 Oct 2015
1 answer
202 views

I have a RadTreeView that I am expanding by applying a style.

<Style TargetType="{x:Type telerik:RadTreeViewItem}">
            <EventSetter Event="Selected" Handler="TreeViewItem_Selected" />
            <Setter Property="IsExpanded" Value="True"></Setter>
        </Style>

 

I am trying to display checkboxes next to items that meet a certain condition. To do this I am trying to hide the checkboxes on those elements that do not meet the condition.

I am hooking into the loaded event of my RadTreeView and trying to iterate down through the items, get the item container and hide the checkbox if necessary.

The problem I am having is that ContainerFromItemRecursive is returning null for any item that is not at the root level.

Here's my code.

private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e)
        {
            RadTreeView rtv = sender as RadTreeView;
 
            foreach (IMeasurementTreeBase item in rtv.Items)
                        {
                            SetCheckBoxVisibilityRecursive(item, rtv);
                        }
            }
        }
 
        public void SetCheckBoxVisibilityRecursive(IMeasurementTreeBase item, RadTreeView rtv)
        {
            if (!item.HasMeasurements())
            {
                RadTreeViewItem treeItem = rtv.ContainerFromItemRecursive(item);
 
                if (treeItem != null)
                {
                    var children = treeItem.ChildrenOfType<CheckBox>().ToList();
 
                    children[0].Visibility = Visibility.Collapsed;
                }
 
                foreach (IMeasurementTreeBase subItem in item.Children)
                {   
                    SetCheckBoxVisibilityRecursive(subItem, rtv);
                }
            }
        }

 

Thanks

 

Andrew
Top achievements
Rank 1
 answered on 21 Oct 2015
3 answers
107 views

Hi,

I'm trying to remove indenting when grouping items in a GridView.I have it basically working by setting a style for GridViewIndentCell with Visibility Collapsed, however after doing this there is some space "left over" on the right of each grid view row. Could you please let me know how to get rid of it and have the row expand all the way to the right?

 Thanks,

Adrian

Petya
Telerik team
 answered on 21 Oct 2015
2 answers
123 views
Hello,

I am about to end a WPF pivot but I still neeed one thing. In the code below you can see what I have already done but I would like the column "Description" to appear right where it is in the RadPivotGrid but I don't want it to be a Aggregate field. Now when the RadPivotGrid loads the data I can see "1" for every row in the column "Description" instead of the text. How should I define this field?

Thanks.

<pivot:LocalDataSourceProvider x:Key="dataProvider">
    <pivot:LocalDataSourceProvider.RowGroupDescriptions>
        <pivot:PropertyGroupDescription PropertyName="Type" />
        <pivot:PropertyGroupDescription PropertyName="Type2" />
    </pivot:LocalDataSourceProvider.RowGroupDescriptions>
     
    <pivot:LocalDataSourceProvider.AggregateDescriptions>
        <pivot:PropertyAggregateDescription PropertyName="Description"  />
        <pivot:PropertyAggregateDescription PropertyName="InitialDate" />
        <pivot:PropertyAggregateDescription PropertyName="Price" />
        <pivot:PropertyAggregateDescription PropertyName="Units" />
    </pivot:LocalDataSourceProvider.AggregateDescriptions>
</pivot:LocalDataSourceProvider>
J
Top achievements
Rank 1
 answered on 21 Oct 2015
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
Slider
Expander
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?