1. Image的Source设定,引用的图片文件在其他的dll中。图片的Build action : Resource
如果是直接写:
Source="/MyProject.Resources;Component/Images/Icon.gif"
如果是binding
Source="{Binding Path=Path}" // code behind: Path = "pack://application:,,,/MyProject.Resources;component/Images/Icon.gif";
2. C#执行外部Exe
Process proc = new Process(); proc.StartInfo = new ProcessStartInfo() { FileName = @"abc.pdf" //put your path here }; proc.Start();
3. Listbox 选中item不高亮
<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 WPF
<StackPanel FocusManager.FocusedElement="{Binding ElementName=Box}">
<TextBox Name="Box" />
</StackPanel>
5. 2014-12-09 DataGrid中,默认会选中第一行,如果想取消选中。以后都不选。可以这样:
<DataGrid x:Name="data" IsSynchronizedWithCurrentItem="{x:Null}" ...>