在xmal預斷行的位置加上
[ 學習筆記 ]
僅是個人筆記,資訊未必正確請見諒
##HIDEME##
2012年11月15日
[銀光] DataGrid header 斷行
1.手動折行
在xmal預斷行的位置加上
2.使用DataGridColumnHeader的template
參考連結
DataGrid column header text wrapping in silverlight
在xmal預斷行的位置加上
2012年10月19日
[銀光] 加入 resource file by code
因為我是使用PRISM, 所以在Shell()中加入
private static Listresources = new List () { "/專案名稱;component/路徑.xaml", "/Resource;component/Styles/BaseChartStyle.xaml" }; ResourceDictionary dictionary; foreach (var url in resources) { dictionary = new ResourceDictionary(); dictionary.Source = new Uri(url, UriKind.RelativeOrAbsolute); Application.Current.Resources.MergedDictionaries.Add(dictionary); }
2012年10月4日
[銀光] 使用Command和CommandParameter
雖然到現在我還是不太懂對於 Button 使用 Command 跟 Click_Event 有什麼差別...
一樣是使用 Prism & MEF,Command 的部分是用 Prism.Commands
小小的寫個 Demo,輸入名字送出會透過 Command 執行 function 並且傳遞 CommandParameter 的值,顯示 Hello XXX,若沒輸入名字則會顯示 Hello Stranger
Xmal
ViewModelBase.cs (只是把值變更時的 PropertyChanged 抽出來)
ViewModel.cs
Sample Code 下載 - file name: Demo_ICommand.rar
一樣是使用 Prism & MEF,Command 的部分是用 Prism.Commands
小小的寫個 Demo,輸入名字送出會透過 Command 執行 function 並且傳遞 CommandParameter 的值,顯示 Hello XXX,若沒輸入名字則會顯示 Hello Stranger
Xmal
<Button Content="Submit" Command="{Binding btnCommand}" CommandParameter="{Binding ElementName=tbName}" />
<sdk:Label Content="Hello" />
<sdk:Label Name="lbName" Content="{Binding Name}" />
xmal.cspublic View()
{
InitializeComponent();
ViewModel model = new ViewModel();
this.DataContext = model;
}
ViewModelBase.cs (只是把值變更時的 PropertyChanged 抽出來)
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
ViewModel.cs
public class ViewModel : ViewModelBase
{
public ICommand btnCommand { get; private set; }
private bool CanSubmit(object arg) { return true; }
private string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
OnPropertyChanged("Name");
}
}
public ViewModel()
{
this.btnCommand = new DelegateCommand<object>(this.Exec, this.CanSubmit);
}
private void Exec(object o)
{
TextBox tb = (TextBox)o;
if (String.IsNullOrEmpty(tb.Text))
{
Name = "Stranger";
}
else
{
Name = tb.Text;
}
}
}
Sample Code 下載 - file name: Demo_ICommand.rar
[銀光] 外部載入資源檔
要把資源檔獨立成一個專案的時候,不知道為什麼一直鬼打牆地失敗。
一直顯示無法指派給屬性 'System.Windows.ResourceDictionary.Source'
新弄一個小專案檔嘗試的時候就意外順利 0rz
要注意的是
1. Main application 要 reference Reousrce 的專案檔
2. 若是其他 Module 專案也要使用的話, 也要記得 reference
3. Resource Dictionary 的 Build Action 設成 Resource
使用方法 - 在 Xmal 裡面引入檔案
Ps: 此程式有使用Prism + MEF, 不過沒啥咪干係就是了...
一直顯示無法指派給屬性 'System.Windows.ResourceDictionary.Source'
新弄一個小專案檔嘗試的時候就意外順利 0rz
要注意的是
1. Main application 要 reference Reousrce 的專案檔
2. 若是其他 Module 專案也要使用的話, 也要記得 reference
3. Resource Dictionary 的 Build Action 設成 Resource
使用方法 - 在 Xmal 裡面引入檔案
<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/專案名稱;Component/資料夾名稱(如果有的話)/檔案名稱.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources>Sample Code 下載 - file name: Demo_Resources.rar
Ps: 此程式有使用Prism + MEF, 不過沒啥咪干係就是了...
[銀光] 如何更改Bar Style
在 PointTemplate 內加入以下 Code 就可以變更長條圖的顏色
※純色
※漸層版本
※純色
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF013E65" Offset="0.431"/>
<GradientStop Color="#FFF9FAFA"/>
<GradientStop Color="#FF04619C" Offset="0.828"/>
<GradientStop Color="#FFD3DADC" Offset="0.091"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
※漸層版本
<telerik:BarSeries.PointTemplate>
<DataTemplate>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF013E65" Offset="0.431"/>
<GradientStop Color="#FFF9FAFA"/>
<GradientStop Color="#FF04619C" Offset="0.828"/>
<GradientStop Color="#FFD3DADC" Offset="0.091"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
</telerik:BarSeries.PointTemplate>
訂閱:
文章 (Atom)
