我正在開發一個進度矩形滑塊[見圖]。 此代碼無法動態設置寬度下載音頻的進度滑塊
public class AudioSlider : Slider, INotifyPropertyChanged {
public AudioSlider() {
DefaultStyleKey = typeof(AudioSlider);
}
#region PropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name) {
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(name));
}
#endregion
private double _trwidth;
public double TrackProgressWidth {
get { return _trwidth; }
set {
_trwidth = value; OnPropertyChanged("TrackProgressWidth");
}
}
...
xaml。 默認樣式...
<Rectangle x:Name="HorizontalFillLoaded" Height="12" MaxWidth="{Binding TrackProgressWidthMax,ElementName=audio}" Width="{Binding TrackProgressWidth,ElementName=audio}" IsHitTestVisible="False" Grid.Column="1" Fill="Black" Margin="0,0,0,28" />
....
我需要改變的 「HorizontalFillLoaded」 寬,像
var t=new AudioSlider();
t.SetDownloadedProgress(50);//50%
好看! :) ... – Pacane 2012-08-07 11:45:31