WPF - 這是一堆代碼片斷的集合

1. Image的Source設定,引用的圖片文件在其餘的dll中。圖片的Build action : Resourceapp

若是是直接寫:ui

Source="/MyProject.Resources;Component/Images/Icon.gif"  

若是是bindingspa

Source="{Binding Path=Path}"

// code behind:
Path = "pack://application:,,,/MyProject.Resources;component/Images/Icon.gif";

 2. C#執行外部Execode

            Process proc = new Process();
            proc.StartInfo = new ProcessStartInfo()
            {
                FileName = @"abc.pdf" //put your path here
            };
            proc.Start();

 3. Listbox 選中item不高亮component

<Style.Resources>
    <!-- Background of selected item when focussed -->
    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                     Color="Green"/>
    <!-- Background of selected item when not focussed -->
    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
                     Color="LightGreen" />
</Style.Resources> 

4. set focus in textbox in WPFblog

<StackPanel FocusManager.FocusedElement="{Binding ElementName=Box}">
   <TextBox Name="Box" />
</StackPanel>

  

5. 2014-12-09 DataGrid中,默認會選中第一行,若是想取消選中。之後都不選。能夠這樣:圖片

<DataGrid x:Name="data"  IsSynchronizedWithCurrentItem="{x:Null}" ...>
相關文章
相關標籤/搜索