Telerik Forums
UI for WPF Forum
1 answer
160 views
Hello. I kind of necroposted in other thread about this issue. That thread seems to be inactive though, so I thought I might as well start a new one, and add some context.

So, long story short, I am trying to implement MVVM with RadDocking and I am having troubles with data binding. Whenever I call LoadLayout method all the binidings that were set in templates break, and i don't know how to fix them.

This is the global style, I'm applying to RadPanes:

<DataTemplate x:Key="HeaderTemplate">
    <StackPanel Orientation="Horizontal">
        <Image Margin="0,0,3,0" Source="{Binding Screen.IconSource}" Width="16" Height="16""/>
        <TextBlock Text="{Binding Screen.Title}"/>
    </StackPanel>
</DataTemplate>
 
<Style TargetType="{x:Type Controls:RadPane}">
    <Setter Property="HeaderTemplate" Value="{StaticResource HeaderTemplate}"/>
    <Setter Property="TitleTemplate" Value="{StaticResource HeaderTemplate}"/>
</Style>

This is my viewmodel class which represents a single pane:
public class ScreenViewModel
{
        public ScreenViewModel(IScreen screen)
        {
            Screen = screen;
        }
 
        public IScreen Screen { get; private set; }
         
        private RadPane _pane;
          //this property is set in DockingPanesFactory.CreatePaneForItem method
        public RadPane Pane
        {
            get { return _pane; }
            set
            {
                _pane = value;
                _pane.Content = Screen.View;
                _pane.Header = this;
                RadDocking.SetSerializationTag(_pane, Screen.ContentId);
            }
        }
//+some other irrelevant properties
}
 
//this is my model
interface IScreen
{
    UIElement View { get; }
    string Title { get; }
    string ContentId { get; }
    ImageSource IconSource { get; }
}

And this is how I load the layout:
public ObservableCollection<ScreenViewModel> Screens { get; set; }
 
public void Load(string file, IScreenFactory screenFactory)
{
    if (!File.Exists(file)) return;
    Screens.Clear();
    using (var fs = File.OpenRead(file))
    {
        var doc = XDocument.Load(fs);
        foreach (var screenId in doc.Descendants("RadPane").Select(x => x.Attribute("SerializationTag").Value))
        {
            //some factory wich creates models by their IDs
            IScreen screen = screenFactory.RestoreScreen(screenId);
            Screens.Add(new ScreenViewModel(screen));
        }
        if (Screens.Any())
        {
            fs.Position = 0;
            //after this call all template the bindings break
            _radDocking.LoadLayout(fs);
        }
    }
}
After the LoadLayout call I can see that header content is set, and that the template is applied, but the bindings set by this template are broken (VS Output is flooded by binding exceptions), which results in empty pane headers. What am I doing wrong?

Nikita
Top achievements
Rank 1
 answered on 11 Mar 2015
9 answers
526 views
Hi

I created a new wpf app and followed the information in the forum to make the main window a RadWindow.  When I execute the program I get a wpf navigation window with my RadWindow inside of it.   The RadWindow appears to be frozen,  Outside the Navigation window is another RadWindow that is not frozen.  Based on the forum guide I think I am doing everything correctly.  I am also using the latest version of the telerik libraries.  I am expecting to see only a main RadWindow with no navigation window.

1. - Created a new Wpf Application

2. Modified MainWindow.Xaml 

<telerik:RadWindow x:Class="CloudburstDataReader.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Header="Cloudburst Data Reader" Height="350" Width="525">
    <Grid>

    </Grid>
</telerik:RadWindow>

3. Modified App.xaml.cs

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            new MainWindow().Show();
            base.OnStartup(e);
        }

    }

4. Modified CloudburstDataReader.cs

namespace CloudburstDataReader
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RadWindow
    {
        public MainWindow()
        { 
            InitializeComponent();
        }
    }
}


    
ToddR
Top achievements
Rank 1
 answered on 10 Mar 2015
2 answers
100 views
When I bind a GridViewDataColumn to a DateTime field, I am not allowed to set the Time.  Seems like a reasonable expectation. 

The default state of the column seems to give us the worst of both worlds because the time is displayed when not edited but when we are in edit mode I can't change it.  If the default is just a calendar then don't display the time in the column.  If the default is to handle time then expose the RadDateTimeEditor instead of the RadDateEditor while editing.

How can I accomplish what I want?  Is it a setting in XAML or do I need to capture the column on creation and define it differently?  I'm always appreciative of XAML and Code examples.

Joel.
Joel Palmer
Top achievements
Rank 2
 answered on 10 Mar 2015
1 answer
193 views
Hi,

I am creating a wpf application with MVVM pattern. The application has a radscheduleview component with context menu attached to it. When user select the "Delete Note" menu item, how can I get all selected appointments into the list which I can then go through, and do desired manipulations to each appointment?

Currently I have a command which delete one appointment at a time. A new requirement is deletion of all selected appointments. Any ideas?

        public RelayCommand<CustomAppointment> DeleteNoteCommand
        {
            get
            {
                return deleteNoteCommand
                    ?? (deleteNoteCommand = new RelayCommand<CustomAppointment>(
                                          p =>
                                          {
                                              if (p != null)
                                              {
                                                  var message = new DialogMessage("Delete Note?", DeleteNoteCallback)
                                                  {
                                                      Button = MessageBoxButton.OKCancel,
                                                      Caption = "Delete Note",
                                                      Icon = MessageBoxImage.Warning
                                                  };
                                                  deletedNote = p; // global variable to send selected item to messenger
                                                  Messenger.Default.Send(message);
                                              }
                                          },
                                          p => (p != null) && (p.Source == NOTE));
            }
        }
Nasko
Telerik team
 answered on 10 Mar 2015
1 answer
175 views
Hi, in the following code I get an exception when i try to drag the content (not the header) of a RadTileViewItem

<Window x:Class="TelerikTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/System.Windows.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.Docking.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.Navigation.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  </Window.Resources>
  <telerik:RadDocking>
    <telerik:RadDocking.DocumentHost>
      <telerik:RadPaneGroup x:Name="Group1">
        <telerik:RadPane x:Name="Pane1" Header="Server Explorer">
          <telerik:RadTileView>
            <telerik:RadTileViewItem Header="Test">
              <TextBlock Text="Start to drag here to crash"/>
            </telerik:RadTileViewItem>
          </telerik:RadTileView>
        </telerik:RadPane>
      </telerik:RadPaneGroup>
    </telerik:RadDocking.DocumentHost>
  </telerik:RadDocking>
  
</Window>

Am I doing something wrong here? I tried it in in Q1 2015 release and in a release from 2014

The last part of stacktrace is

An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.Windows.Controls.Docking.dll

  Telerik.Windows.Controls.Docking.dll!Telerik.Windows.Controls.RadPane.OnDragInitialize(object sender, Telerik.Windows.DragDrop.DragInitializeEventArgs e) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializeEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Unknown
  PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) Unknown
  PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) Unknown
  PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDrag() Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(System.Windows.UIElement sender) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(object sender, System.Windows.Input.MouseEventArgs e) Unknown
  PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) Unknown


...
Geri
Telerik team
 answered on 10 Mar 2015
3 answers
151 views
How can add possibility for selecting range of chart using radcartesianchart?
Milena
Telerik team
 answered on 10 Mar 2015
3 answers
922 views
I want to round the corners on a RadComboBox, but I don't want to go through and edit the template for it. Is there way to do that without going through the hassle of doing that? Potentially just using a setter property or something to do it on the xaml side?

thanks.
Nasko
Telerik team
 answered on 10 Mar 2015
4 answers
346 views
Hello,

I have a RadGridView, it has 7 columns with boolean data. I want to disable each cell with a true value.

I created a style and a converter, I add the style at runtime using the grid DataLoaded event:

<Style x:Key="myCellStyle" TargetType="{x:Type telerik:GridViewCell}">
            <Setter Property="IsEnabled" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource myConverter}}" />
        </Style>
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            GridViewCell cell = (GridViewCell)value;

            if(cell.Value == null)
                return true;
            else
                return (bool)cell.Value;
        }

private void grid_DataLoaded(object sender, EventArgs e)
        {
            foreach (Telerik.Windows.Controls.GridViewColumn col in gridCheck.Columns)
            {
                    col.CellStyle = (Style)this.Resources["myCellStyle"];
                
            }
        }

In the converter I get a GridViewCell object in the value parameter, but the GridViewCell.Value property is always null.

How can I pass the value of the cell to the converter?

Thanks in advance,

Alberto
Amige
Top achievements
Rank 1
Veteran
 answered on 09 Mar 2015
2 answers
222 views
I have a spreadsheet control I am going to use for data input.  Some cells will need data validation which will pop up a message about the error, and put the red circle around it.  I have the spreadsheet control on the form and set my Imports statements, I do not have a ribbon bar on the form.  We do not want to allow the users to change the form, just input data.  When I put in the following line:

Dim context as new NumberDataValidationRuleContext...

I get type not defined.  I will need to apply different rule types to different cells, some whole numbers, some decimals, some letters all with ranges. For example 8-12 for hole numbers, .5-3.0 for decimal, A-B for letters. 

I looked through the documentation and must have missed something.  How do I apply Validation to cells to ensure they are within the ranges?
John
Top achievements
Rank 1
 answered on 09 Mar 2015
4 answers
97 views
Hello,

I am trying to add some control to the pane header, I saw this documentation about that, it seems that it's not very complicated using the TitleTemplate property.
The difference in my project is that I am creating the RadPane at runtime. Is it possible to programatically add a control to the pane header? Also I would like to add events to that control.

Thanks in advance,

Alberto 



 
Amige
Top achievements
Rank 1
Veteran
 answered on 09 Mar 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
Expander
Slider
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
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?