刷新自定义控件Xaml / lightswitch

时间:2013-03-15 08:57:34

标签: xaml silverlight-4.0 controls lightswitch-2012

我在Lightswitch中创建了一个应用程序,并使用了this自定义控件。

问题是当我更改控件的值时。

可能无法动态更改控件,必须刷新才能获得新值。

所以我需要知道如何刷新控件或部分屏幕。

这是控制代码的外观

<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>

这种方式是我如何设置绑定到值

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

这样我改变了控制属性

SilverlightCustomControls.Amount.amount = 10000;

我找不到任何关于刷新或重新加载XAML控件或只刷新lighswitch屏幕的一部分... thx任何帮助

1 个答案:

答案 0 :(得分:0)

Lightswitch自动刷新组件如果它们是数据绑定的。因为您只是设置值,所以不会刷新控件。你能不把控制权绑在你的财产上吗?然后当你在代码中更改它时,控件应该自动刷新?

<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>