Cell Size for RadDiagram doesn't change

7 posts, 0 answers
  1. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 24 Nov 2014 Link to this post

    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.
  2. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 24 Nov 2014 in reply to Alaa Link to this post

    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;
            }
        }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 26 Nov 2014 in reply to Alaa Link to this post

    Any help??
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 26 Nov 2014 Link to this post

    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.

     
  6. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 27 Nov 2014 Link to this post

    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! 
  7. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 27 Nov 2014 Link to this post

    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
  8. Alaa
    Alaa avatar
    27 posts
    Member since:
    Jun 2014

    Posted 27 Nov 2014 in reply to Alaa Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready