##HIDEME##

2012年11月15日

[銀光] DataGrid header 斷行

1.手動折行
在xmal預斷行的位置加上

2.使用DataGridColumnHeader的template 
 參考連結 DataGrid column header text wrapping in silverlight

2012年10月19日

[銀光] 加入 resource file by code

因為我是使用PRISM, 所以在Shell()中加入
private static List resources = 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
<Button Content="Submit" Command="{Binding btnCommand}" CommandParameter="{Binding ElementName=tbName}" />

<sdk:Label Content="Hello" />

<sdk:Label Name="lbName" Content="{Binding Name}" />
xmal.cs


public 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 裡面引入檔案
<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>


2012年10月3日

[銀光] http://schemas.microsoft.com/expression/blend/2008 is not resolved

如果出現了
http://schemas.microsoft.com/expression/blend/2008 is not resolved
這個錯誤
那一定就是少加了以下這三條

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"

2012年6月23日

[芒果] Wallpapers

桌布其實就只是螢幕鎖定(待機)的時候,顯示出來的圖片。
如何設定/ 修改 WP7 芒果機的桌布? 順便找出些你沒看過的桌布!

幾個桌布的網站
http://wpwallpaper.com/
http://blog.levifreeman.com/2012/05/official-windows-phone-wallpapers/
http://www.nokiadna.com/wallpaper-2/nokia-lumia-and-windows-phone/

推薦一個好用的 wallpapers app - [+]LockScreen Lite
有很多漂亮的 wallpaper 還可以 DIY 日曆。

App畫面預覽:


下載:



[芒果] 閱讀小說軟體 - 書中聖


官網:http://mohoo.cc

免費又好用的瀏覽小說APP,可以下載小說,或是自己把小說放進來。
支援TXT、UMD、ePub、ZIP、RAR格式,或是支援從SkyDrive匯入。
※ps: 要把TXT存成Unicode,這樣子看才不會是亂碼唷

若要從電腦把檔案放入的話,得要先去官網下載管理程式,電腦必須已經安裝 .NET 4.0 以及 SQL Server Compact 3.5

使用方法:
1. 打開管理器後,先點選啟動服務
2. 打開App以後,在管理→同步+導入→管理器同步,設定如下圖上面所列的IP。
3. 預設的位子在可以點選管理器右上方的設置,就是PC同步下載後的位子了。


App畫面預覽:
 


下載: