Telerik Forums
UI for WPF Forum
1 answer
605 views

Hi @ll,

 

I need your help. After searching the internet for several hours I have
no solution for my problem.

 

I have an enum property which I bind to a GridViewComboBoxColumn
using the following xaml code:

<telerik:GridViewComboBoxColumn ItemsSourceBinding="{Binding Options}"
        DataMemberBinding="{Binding Position}"
        DisplayMemberPath="Value"
        SelectedValueMemberPath="Key"/>

 

Options is a property which maps the enum value to a string:

public enum Pos
{
    A, B, C
}
 
public class DisplayObject<T>
{
    private readonly T key;
 
    private readonly string val;
 
    public DisplayObject(T key, string val)
    {
        this.key = key;
        this.val = val;
    }
 
    public T Key => this.key;
 
    public string Value => this.val;
}

 

public IEnumerable<DisplayObject<Pos>> Options
{
    get
    {
        yield return new DisplayObject<Pos>(Pos.A, "HUGO");
        yield return new DisplayObject<Pos>(Pos.B, "EGON");
        yield return new DisplayObject<Pos>(Pos.C, "WILLI");
    }
}

 

Grid works fine. But there are some problems with the FilteringControl.

I want the FilteringControl to uses the DisplayMemberPath to display
the DistinctValues and ComboBox Options.

 

Can anyone help me solving my problem?

 

public class Item : INotifyPropertyChanged
{
    private Pos pos;
 
    private string name;
 
    public Item(string name, Pos pos)
    {
        this.name = name;
        this.pos = pos;
    }
 
    public string Name
    {
        get
        {
            return this.name;
        }
    }
 
    public Pos Position
    {
        get
        {
            return this.pos;
        }
 
        set
        {
            if (this.pos == value)
            {
                return;
            }
 
            this.pos = value;
            this.OnPropertyChanged(nameof(this.Position));
        }
    }
 
    public IEnumerable<DisplayObject<Pos>> Options
    {
        get
        {
            yield return new DisplayObject<Pos>(Pos.A, "HUGO");
            yield return new DisplayObject<Pos>(Pos.B, "EGON");
            yield return new DisplayObject<Pos>(Pos.C, "WILLI");
        }
    }
 
    public event PropertyChangedEventHandler PropertyChanged;
 
    [NotifyPropertyChangedInvocator]
    protected virtual void OnPropertyChanged(string propertyName)
    {
        this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}
<Window x:Class="ChangeDefaultFilterOperator.MainWindow"
        xmlns:my="clr-namespace:ChangeDefaultFilterOperator"
        Title="MainWindow" Height="700" Width="700">
    <Window.Resources>
        <my:MyViewModel x:Key="MyViewModel"/>
    </Window.Resources>
    <Grid DataContext="{StaticResource MyViewModel}">
        <telerik:RadGridView ItemsSource="{Binding Items}"
                             AutoGenerateColumns="False"
                             Margin="5">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
 
                <telerik:GridViewComboBoxColumn ItemsSourceBinding="{Binding Options}"
                                                DataMemberBinding="{Binding Position}"
                                                DisplayMemberPath="Value"
                                                SelectedValueMemberPath="Key"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>
public class MyViewModel
{
    private readonly ObservableCollection<Item> items;
 
    public MyViewModel()
    {
        this.items = new ObservableCollection<Item>
                     {
                         new Item("AAA", Pos.A),
                         new Item("BBB", Pos.B),
                         new Item("CCC", Pos.C)
                     };
    }
 
    public ObservableCollection<Item> Items
    {
        get
        {
            return this.items;
        }
    }
}

Stefan
Telerik team
 answered on 01 Feb 2017
0 answers
118 views

Hello All,

    I am using WPF and MVVM.   I have a observable collection of objects that I am displaying in the grid.   I am trying to add a new column at the beginning of the gridview that has a button in it .  This button needs to fire off a command in my ViewModel.  In the command's execute method, I need to edit some of the properties of the entity that that row represents in my observable collection.  I am assuming that I'll need to pass some sort of parameter to the command to send in either the row contents or some event args for the button being clicked...   But I'm not exactly sure what I need to do.    I would interested the most in doing this WITHOUT any code-behind in the View, and do this some way with the XAML and ViewModel code, trying to keep in the MVVM frame of mind...  Any help will be greatly appreciated!

Thanks in advance,

 

Kevin Orcutt

Kevin
Top achievements
Rank 1
 asked on 31 Jan 2017
6 answers
169 views

Hello,

I have written a Custom Command Descriptor based on the Telerik demos and documentation that exports the currently loaded document to a local file. Everything appears to be working 100% correct with no errors. However, when I open the file all the pages are blank. The page count is correct, so it appears to be reading the PDFViewer document correctly into the stream, just not writing all of the bytes properly. Here is my code behind for the page that contains the Document Viewer control.

 

using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Telerik.Windows.Documents.Fixed.FormatProviders;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.Model;
using WeldTrackingWPF.ViewModel;
using Telerik.Windows.Controls;
using Telerik.Windows.Documents.Commands.Descriptors;
using Telerik.Windows.Documents.Commands;
 
namespace WeldTrackingWPF.View
{
    /// <summary>
    /// Interaction logic for ViewQualificationDoc.xaml
    /// </summary>
    public partial class ViewDoc : Page
    {
        public ViewDoc(byte[] fileBytes)
        {
 
            InitializeComponent();
 
            /// <summary>
            ///  Read bytes into memory stream
            ///  Pass stream in RadPdfViewer for viewing
            /// </summary>
 
 
            this.pdfViewer.CommandDescriptors = new CustomCommandDescriptors(this.pdfViewer);
 
            Stream stream = new MemoryStream(fileBytes);
 
            FormatProviderSettings settings = new FormatProviderSettings(ReadingMode.AllAtOnce);
 
            PdfFormatProvider provider = new PdfFormatProvider(stream, settings);
 
            RadFixedDocument doc = provider.Import();
 
            this.pdfViewer.Document = doc;
 
            IconSources.ChangeIconsSet(IconsSet.Modern);
 
 
 
        }
 
        private void Page_Initialized(object sender, EventArgs e)
        {
            var vm = new ViewDocViewModel();
            DataContext = vm;
        }
 
        private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
        {
        }
 
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {             
        }
 
        private void tbCurrentPage_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox textBox = sender as TextBox;
            if (textBox != null)
            {
                if (e.Key == System.Windows.Input.Key.Enter)
                {
                    textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                }
            }
        }
    }
 
    public class SaveCommand : FixedDocumentViewerCommandBase
    {
        public SaveCommand(FixedDocumentViewerBase fixedDocumentViewerBase)
            : base(fixedDocumentViewerBase)
        {
        }
 
        public override void Execute(object parameter)
        {
            Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog();
            dialog.Filter = "PDF files (*.pdf)|*.pdf";
 
            bool? result = dialog.ShowDialog();
 
            if (result.HasValue && result.Value)
            {
 
                using (Stream stream = File.OpenWrite(dialog.FileName))
                {
 
                    PdfFormatProvider provider = new PdfFormatProvider();
                    provider.Export(this.Viewer.Document, stream);
 
                }
            }
        }
    }
 
    public class CustomCommandDescriptors : DefaultCommandDescriptors
    {
        private readonly CommandDescriptor saveCommandDescriptor;
 
        public CommandDescriptor SaveCommandDescriptor
        {
            get
            {
                return this.saveCommandDescriptor;
            }
        }
 
        public CustomCommandDescriptors(FixedDocumentViewerBase fixedDocumentViewer) : base(fixedDocumentViewer)
        {
            this.saveCommandDescriptor = new CommandDescriptor(new SaveCommand(fixedDocumentViewer));
        }
    }
 
}

Any insight as to why these documents are being exported sans page content would be appreciated.

 

Thanks!

Tanya
Telerik team
 answered on 31 Jan 2017
7 answers
237 views
Hello,

I noticed some binding errors in my output window that I could not explain at first:

System.Windows.Data Warning: 40 : BindingExpression path error: 'Title' property not found on 'object' ''String' (HashCode=1191344071)'. BindingExpression:Path=Title; DataItem='String' (HashCode=1191344071); target element is 'ContentPresenter' (Name='Content'); target property is 'ResourceKey' (type 'String')

after some meddling around, I finally found out that what was causing those errors where the viewDefinitions in the ScheduleView object.

it appears that I always have as many binding errors as viewDefinitions, no matter how many viewDefinitions I add to the object. So I'm guessing something is wrong with the way the viewDefinition's Title property is bound in the template. (I add "blank" viewDefinitions, with nothing set, not even the title, and I get this error. NB: the title seems to be displayed correctly, though...)

can you confirm this? or is this something on my side that I have not understood ?
Stefan Nenchev
Telerik team
 answered on 31 Jan 2017
1 answer
114 views
Hi everyone,
we use a collection with dynamic objects which is binded to a RadGridView. 
All colums and rows are shown correctly but unfortunatly the integrated search function (ctrl + f) does not search within attributes which are added dyanmically to the objects.
It works only for attributes which are directly implemented.

Is it a common behaviour of the search function or may be a bug \ missing feature?

Thank you for your help!
Stefan Nenchev
Telerik team
 answered on 31 Jan 2017
1 answer
373 views
Hi my appointments have a active flag and when it's false, I would like the delete button to hide. I was reading that I should edit the schedule view xaml code but my bindings aren't correct. Any ideas?

<telerik:RadButton x:Name="DeleteButton"
            Style="{StaticResource DeleteButtonStyle}"
            Command="{x:Static local:RadScheduleViewCommands.DeleteAppointment}"
            ClickMode="Press"
            CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
            Visibility="{Binding Active, Converter={StaticResource BooleanToVisibilityConverter}}"
            IsTabStop="False" />

               
Yana
Telerik team
 answered on 31 Jan 2017
5 answers
257 views
Is there a way to get the calculator picker to display 1.00 instead of just 1?  I want to use it to display money values and 1.00 feels better than just 1.

Dilyan Traykov
Telerik team
 answered on 30 Jan 2017
3 answers
127 views

Hi,

 

I have successfully used the AsyncSqlGeospatialDataReader to read shape data stored in a geometry column in SQL. I first read the geometry objects into a local collection and then assign that collection to the reader

var readerRail = new Telerik.Windows.Controls.Map.SqlGeospatialDataReader();
readerRail.Source = RailShapes;
readerRail.ToolTipFormat = "{SegmentLabel}";
readerRail.GeospatialPropertyName = "ShapeWKT";
readerRail.PreviewReadCompleted += readerRail_PreviewReadCompleted;
 

However, while this has worked on three previous collections on this specific one I get a "Non-static method requires a target" error. It seems as if some of the shape data must then be an issue but I have no idea where to start looking.

 PS: SQL Management studio can query the data and display it

 

Dinko | Tech Support Engineer
Telerik team
 answered on 30 Jan 2017
1 answer
207 views

Hi Team,

I'm just trying to insert a telerik docking Control, but it's not visible in the designer.

Code:

<telerik:RadDocking  MinHeight="70" Margin="2,2,2,2" Height="100" Width="1300" Background="#E5E5E5" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"  >
                        <telerik:RadDocking.DocumentHost>
                            <telerik:RadDockPanel>
                                <telerik:RadPaneGroup>
                                    <telerik:RadPane Header="Docking">
                                        <TextBlock Text="HOIxhskaxhksaj"/>
                                    </telerik:RadPane>
                                </telerik:RadPaneGroup>
                            </telerik:RadDockPanel>
                        </telerik:RadDocking.DocumentHost>
                    </telerik:RadDocking>

Stefan
Telerik team
 answered on 30 Jan 2017
1 answer
78 views

Hi,  I have a wpf application which main area is RadDocking control with DocumentHost and so on.  Actually it is Tab MDI application based on RadDocking.  I would like to drag and drop files to this area of the application from windows explorer. For RadDocking I can handle PreviewDrop event,  but Drop event is not raised.  Feedback event is not raised to (for custom visual cursor).  I tried to work with DragDropManager but got same behavior.  Allow drop is set true for RadDocking control  and qindow as well.  Solutions? 

Thanks, 

Vladimir 

Nasko
Telerik team
 answered on 30 Jan 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
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?