MVVM support

12 posts, 0 answers
  1. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 04 Mar 2012 Link to this post

    HI,
    we are evaluating silverlight controls, and currently trying DataForm and have two questions:

    1) localization: when a required validation error message is displayed, it displays the field name, and not the label text, which should normally do. Imagine that the validation error notification is localized in Deutch, but the field name is displayed in English. Is there a quick fix for this, or we need to localize all validation messages manually?

    2) How do we utilize DataForm with MVVM? Basically, UI should not be aware of business logic, so when a user adds new entity, we should use command to pass this request to ViewModel. The best solution would include reusing current look of buttons, and be able to apply a different theme to them. This applies to all buttons, except for navigation.

    3) How to set TextAllignment for telerik's DataFormDataField without loosing its style? If I add TextBox to it, and set TextAllignment to it, I loose current theme styling for this element.

    <telerik:DataFormDataField Label="{Binding ...}" DataMemberBinding="{Binding ...}">
        <TextBox Text="{Binding ...}" TextAlignment="Right" />
    </telerik:DataFormDataField>


    Thanks in advance.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 08 Mar 2012 Link to this post

    Hello Goran,

    I will try to answer your inquiries, keeping the same order that you have declared in your list:
    1) We have recently stumbled upon this issue and a fix for it has been scheduled for our incoming Service Pack for Q1 that is meant to be released in 1-2 weeks.
    2) Would you please shed some more light on your concerns about RadDataForm's MVVM support? The control is designed to rely entirely on framework's binding system.
    3) I have prepared an example project that illustrates how to tackle this. Please, refer to the attachment.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 08 Mar 2012 Link to this post

    Hi, Ivan, thanks for the response.

    2) Well, in MVVM scenario adding and removing a record is done in VIewModel using ICommands. Since Add and Remove buttons are not exposed a properties, so the only way that we found to make this work is finding this buttons through their names, and setting Command properties manually in code behind, Is this your recommended approach in MVVM scenario?

    3) Now add reference to Windows7 theme and apply theme in MainPage's constructor:

    StyleManager.ApplicationTheme = new Windows7Theme();
    InitializeComponent();

    You will see that now it doesn't work, and that we lost the theme applied.

    Thanks.
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 12 Mar 2012 Link to this post

    Hello Goran,

    Unfortunately, currently RadDataForm does not provide an approach to achieving this through control's API. I perfectly understand your concerns, so we will discuss this term and will think of introducing some improvements in the close future.
    As for the other inquiry of yours, an alternative workaround that would be compatible with our theming mechanism would be to set the property directly, instead of setting a style.
    I will keep the thread open so that I could notify you as soon as we have made any progress on the MVVM issue.

    Greetings,
    Ivan Ivanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 12 Mar 2012 Link to this post

    Hi, Ivan,

    can you give an example how to set the TextAlignment property directly?
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 13 Mar 2012 Link to this post

    Hello Goran,

    I have updated  my initial project, setting WIndows 7 application theme and replacing the TextBox style. I am attaching it for your reference.

    Regards,
    Ivan Ivanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  8. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 13 Mar 2012 Link to this post

    Ah, you have made me think (want to believe) there is a solution iin xaml for setting the TextAlignment property. I already knew I can do it in code-behind. :)

    I have noticed also that "Input string is not in correct format validation" error is not localized (available after ValidatesOnExceptions is set to true. Is this also a problem with localization similar to my first question?
  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 13 Mar 2012 Link to this post

    Hi Goran,

    Unfortunately currently there is not any clear way to accomplish this in xaml, as DataFormDataField is actually a decorated content control, which content (the TextBox in our case) is set at runtime. However, we are up to introduce some enhancements to our theming mechanism with our incoming Service Pack, which in my opinion will affect your scenario, making it possible to accomplish this in xaml. I will test this as soon as the SP is available and will notify you of the results.
    As for the second inquiry of yours, this error message seems to be a standard framework's exception message. Would you please confirm which is your current ui thread culture and whether changing it solves this issue?

    Regards,
    Ivan Ivanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  10. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 13 Mar 2012 Link to this post

    Thanks Ivan, for all the help.

    Currently in our testing scenario we have implemented a localization switchover in runtime. Basically a user can click on a menu where languages are listed and select a particular language, and all UI is automatically updated. This is achieved through assigning a new culture to CurrentThread.CurrentUICulture (and CurrentCulture) and propagating new values from localized resource files. This all works fine, and for example, a required validation message that I was speaking of in the first question in this topic was properly localized (except for the field name, of course), but if I try to enter a letter in a numeric field, English validation error message is always displayed.
  11. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 13 Mar 2012 Link to this post

    Hi, Ivan,

    just noticed one more thing: in RadDataForm I have next layout

    <DataFormDataField />
    <DataFormDataField />
    <DataFormDataField><RadDateTimePicker /></DataFormDataField>
    <DataFormDataField><RadDateTimePicker /></DataFormDataField>
    <DataFormDataField />
    <DataFormDataField />

    Shift + Tab doesnt work if I an currently edting field number 5, or in another words, I cannot tab back to a DataFormDataField that incorporates RadDateTimePicker control. Tab works without problems, but Shift + Tab experience problems when needs to put focus on RadDateTimePicker
  12. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 13 Mar 2012 Link to this post

    Hello Goran,

    I have tested the localization issue and it appears that the framework uses CultureInfo.InvariantCulture to localize the TypeConverter error messages. I successfully managed to reproduce it with simple Silverlight TextBox. I have attached my test project for your reference. However, I will try to think of some workaround, so I am leaving the thread open for now.
    As for the navigation problem, in order to tackle it, try setting the editors as fields' ContentTemplate, instead of as direct Content. Please, let us know whether this solution works properly for your scenario.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  13. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 14 Mar 2012 Link to this post

    Hi Ivan,

    forget about the problem with Shift + tab. I complained too soon, the problem was in incorrect bindind, since DateTimePicker cannot be bind to TimeSpan, only DateTime, so I needed to make a converter.

    Anyway, we have decided today to buy your products, hoping that this small issues will be overcomed. :)

    Thanks again.
Back to Top
DevCraft banner