1

I am creating an app in Lightswitch and I used this custom control.

The problem is when I change value of the control.

It's probably not possible to change control dynamically, it must be refreshed to get new value.

So I need to know how can I refresh just control or part of the screen.

This is how the control code look

<Grid x:Name="LayoutRoot" Background="White" Width="200" Height="200">
    <GaugeControl:GaugeControl HorizontalAlignment="Left" Margin="10,10,10,10" 
                               Name="gaugeControl1"                       
                               Maximum="25000" Minimum="0" VerticalAlignment="Top"  />
</Grid>

This way is how I set binding to the value

public RadioGauge() {
  InitializeComponent();
  gaugeControl1.Value = Amount.amount; // where Amount is class and amount is int property
}

And this way I change the control property

SilverlightCustomControls.Amount.amount = 10000;

I couldnt find anything about refreshing or reloading XAML control or refreshing just part of lighswitch screen.. thx for any help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Lightswitch automatically refreshes components if they are data bound. Because you are just setting the value, the control is not being refreshed. Can you not bind the control to your property? Then when you change it in code the control should automatically refresh?

<Grid x:Name="LayoutRoot" Background="White" Width="200" Height="200">
    <GaugeControl:GaugeControl  HorizontalAlignment="Left" Margin="10,10,10,10"
                                Name="gaugeControl1"
                                Maximum="25000" Minimum="0"
                                VerticalAlignment="Top"
                                Value="{Binding Screen.SCREENDATASET.SelectedItem.Amount}"  />
</Grid>
RichardC
  • 794
  • 4
  • 13
  • Hello thx for answer this could solve my problem ! but i dont want to work with selected items, is here some way how to bind it for int property which is in lighswitch app in some class ? But thank you very mutch for help ! I allready found out how to bind it to selected item but i think that the control is refreshed after selectinng different item.. – Osel Miko Dřevorubec Mar 15 '13 at 12:24
  • Have a look at this which explains more about the Silverlight Binding syntax: http://msdn.microsoft.com/en-gb/library/cc278072(v=vs.95).aspx It specifically mentions about implementing the `INotifyPropertyChanged` interface in your class, so maybe that would help? – RichardC Mar 15 '13 at 12:59
  • I found how to do it but on different place :-) but it istn still perfect , pls look here if you have any idea [link] (http://stackoverflow.com/questions/15654387/load-lightswitch-properties-to-silverlight-control-after-screen-loaded) – Osel Miko Dřevorubec Mar 27 '13 at 08:24