This is a migrated thread and some comments may be shown as answers.

Cell Size for RadDiagram doesn't change

6 Answers 151 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Alaa
Top achievements
Rank 1
Alaa asked on 24 Nov 2014, 01:04 PM
Hello,
I followed your code for DiagramToolBox in Telerik Demo (please, check the attached image).
But the Cell Size doesn't work! Even I can see the initial value (20,20).
I tried Debug it, It wasn't hitting the setter in the property at all!

I added 
UpdateSourceTrigger=PropertyChanged and Converter={StaticResource DoubleToStringConverter}} to TextBox line. I thought I would need them. But it didn't work!
                           <StackPanel Orientation="Horizontal" Margin="10 12 10 0"><br>                                        <TextBlock Text="Cell Size" Width="90" Margin="20 0" VerticalAlignment="Center" /><br>                                        <TextBox Width="80" Text="{Binding CellSize, Mode=TwoWayUpdateSourceTrigger=PropertyChanged, <br>                                                                                                               Converter=   {StaticResource DoubleToStringConverter}}" /><br>                            </StackPanel>

How it is working in the Demo without a converter ?

Thank you.

6 Answers, 1 is accepted

Sort by
0
Alaa
Top achievements
Rank 1
answered on 24 Nov 2014, 01:43 PM
I made this converter

    public class SizeToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Size dVal = (Size)value;

            if (value != null)
            {
                return value.ToString();
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string bVal = (string)value;

            if (value != null)
            {
                int width, height;
                string[] dims = value.Split(',');
                int.TryParse(dims[0], out width);
                int.TryParse(dims[1], out height);

                return new System.Drawing.Size(width, height);
            }
            return null;
        }
    }
0
Alaa
Top achievements
Rank 1
answered on 26 Nov 2014, 06:20 AM
Any help??
0
Pavel R. Pavlov
Telerik team
answered on 26 Nov 2014, 03:30 PM
Hi Alaa,

I first would like to say that using a converter is the most convenient way to debug a binding expression. I personally use it in my everyday work and I am happy that you are doing the same.

As for the issue you have encountered - I will try to explain why the binding does not kick in even though you have set the proper properties in the style. The reason behind this issue is the fact that in the referenced demo project the background grid is hidden. By default it is visible but in that particular demo the grid is hidden on purpose. The grid should be visualized in order to be customized by the CellSize property.

This is done by using the IsGridVisible property. You can find more information about it in our Customize Appearance article. You can also see in the code of the demo that it is bound to a checkbox which unchecked by default. 

I hope this information is helpful.

Regards,
Pavel R. Pavlov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alaa
Top achievements
Rank 1
answered on 27 Nov 2014, 09:51 AM
Hello,
The problem is, I can't see the initial value for CellSize neither SnapValue at RunTime! I can't hit the setter for both in debug mode!
So, they're definitely not connected with the ViewModel! I checked the ncheckBox when I insert a new value for the CellSize or SnapValue!

I even changed and put two TextBoxes for two double properties. Then I merged them to have a one Size Value. But still the same problem! 
0
Alaa
Top achievements
Rank 1
answered on 27 Nov 2014, 10:53 AM
It worked! The problem was that the textBoxes are not binding to MainView. and that's because I've put DataContext of the main upper border is Diagram, then the textBoxes couldn't see the main DataContext!

Thank You
0
Alaa
Top achievements
Rank 1
answered on 27 Nov 2014, 10:55 AM
I had some mistakes in my previous reply. It should be as the following:

It worked! The problem was that the textBoxes are not binding to MainViewModel, and that's because I've put DataContext of the main upper border is Diagram, then the textBoxes couldn't see the main DataContext (MainViewModel)!

Thank You
Tags
Diagram
Asked by
Alaa
Top achievements
Rank 1
Answers by
Alaa
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or