New Posts New Posts RSS Feed: strange behavior IsbussyIndicator
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

strange behavior IsbussyIndicator

 Post Reply Post Reply
Author
Peer View Drop Down
Newbie
Newbie
Avatar

Joined: 31-Aug-2010
Location: Netherlands
Posts: 15
Post Options Post Options   Quote Peer Quote  Post ReplyReply Direct Link To This Post Topic: strange behavior IsbussyIndicator
    Posted: 10-Sep-2010 at 11:16am
While following the SimpleSteps sample(s) for Silverlight 4.0 , I have noticed the isbusyIndicator(from the toolkit) disturbs the dataform control (also from the toolkit).
Wen data is retrieved from orders  by a query, the navigationbuttons from the dataform control seems te be disabled(color) , but they respond normal. After using the navigationbuttons, the enabled color appears  only when the data is retrieved from cache. Obvious the disabled color is set while querying the database and firing some changed events...
 
It isn't' a big issue but it is interesting to know why this happens. Does somebody have an idea ?
thanks,
Peer
Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 10-Sep-2010 at 7:27pm

We'll have to look at it. Confess that we're just hooking together toolkit controls whose innards are mysterious. Might have missed some essential wiring step. No guarantees. 

Did I happen to mention that I try not to use the DataForm or DataGrid in real code? I think of them as convenient demoware. In a real application I prefer to think through the UX and write an intentional experience rather than reach for the swiss army knife. 
 
Of course this is besides the point. We should make it work even if it is not ours.
 
Doesn't sound like there is great urgency on this subject. We'll get to it.
Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 13-Sep-2010 at 9:44am

Couldn't help peeking. The Toolkit's BusyIndicator does disable/re-enable the DataForm but that has no influence on the DataForm's CommandButtons. Aaargh!  Maybe they'll fix that someday.

How do I know this?
(1) I confirmed your experience of clicking the navigation buttons while the form was supposedly disabled.
(2) In the code-behind I listened to the EmployeeDataForm.IsEnabledChanged event ... which dutifully toggled in sync with the BusyIndicator.IsBusy property.
 
There is no obvious way to talk to the CommandButtons directly (see what I mean about Swiss Army Knife?).
 
You can control their visibility. One palliative approach is to hide the buttons when busy. I took a quick crack at it (remember, this is a DEMO).
 
Three Steps:
1) Bind the DataForm's CommandButtonsVisibility to IsBusy in MainPage.xaml
    Binding will need a ValueConverter because Visibility takes an enumeration and IsBusy is boolean
2) Add a ValueConverter as a resource in MainPage.xaml
3) Write the ValueConverter in the first place
 
Of course I actually proceeded in reverse: 3,2,1
 
3) Add Value Converter
namespace SimpleSteps {
  public class HideDataFormCommandVisibilityConverter : IValueConverter {

    public HideDataFormCommandVisibilityConverter() {
      CommandButtonsVisibility = DataFormCommandButtonsVisibility.All;
    }

    public DataFormCommandButtonsVisibility? CommandButtonsVisibility {getset;} 

    public object Convert(object value, System.Type targetType, 
object parameter, System.Globalization.CultureInfo culture) {
      if (value.GetType() != typeof(bool)) return null;
      return ((bool) value) ? DataFormCommandButtonsVisibility.None : CommandButtonsVisibility;
    }

    public object ConvertBack(object value, System.Type targetType, 
object parameter, System.Globalization.CultureInfo culture) {
      return null;
    }

  }
}
2) Add Resource to UserControl.Resources
<UserControl  x:Class="SimpleSteps.MainPage"
...
    xmlns:local="clr-namespace:SimpleSteps" >




    <UserControl.Resources>
        <local:HideDataFormCommandVisibilityConverter 
            x:Key="HideEmployeeCommandsConverter" 
            CommandButtonsVisibility="Navigation, Add, Delete, Cancel, Commit"/>
    </UserControl.Resources>
3) Bind DataForm's CommandButtonsVisibility
<toolkit:DataForm Name="EmployeeDataForm" Grid.Row="0" 
                  ItemsSource="{Binding Employees}" 
                  EditEnded="dataForm1_EditEnded"
                  CurrentItem ="{Binding CurrentEmployee, Mode=TwoWay}" 
                  CommandButtonsVisibility="{Binding IsBusy, 
                    Converter={StaticResource HideEmployeeCommandsConverter}, Mode=TwoWay}"
                  />
I remind you again that this is demo code. Plenty of other gotchas; there is no error handling, for example ... as the code makes clear with plenty of "ToDo" comments.
 
HTH
Back to Top
Peer View Drop Down
Newbie
Newbie
Avatar

Joined: 31-Aug-2010
Location: Netherlands
Posts: 15
Post Options Post Options   Quote Peer Quote  Post ReplyReply Direct Link To This Post Posted: 14-Sep-2010 at 1:33am
Hi Ward,
 
Thank you for your investigation. I Implemented the snippets but it didnt solve the problem. The buttons dis/appears as aspected but the control's state seems to be disabled when fetching data from the database. If you click on a controle-item such as button or textbox (set the focus), the enabled state is restored.
 
Again, this isn't a big issue but is makes me wonder if the toolbox is a good and reliable source. I Move forward and  downladed the PrismExplorer to evaluate the code and architecture, and hopefully I find more complex situations according to normal business reality. I realy enjoyed your TechEd video presentation about Prism though sometimes it is hard to understand all the concepts and jokes because English is not my native language.
 


Edited by Peer - 14-Sep-2010 at 6:16am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down