When you use Visual Studio 2010, you will find there is no a WPF chart control in toolbox. The WPF chart control does not followed with .NET 4.0 release, It is still in .NET 3.5 WPFtoolkit. You might have to download the WPF toolkit and install it. But please check before you download and install, [Read More ...]
Sample 1: public string MyText {get;set;} the binding is {Binding MyText , RelativeSource={RelativeSource FindAncestor, AncestorType=Window}} Or <Window Name="MyWindow" … <TextBlock Text="{Binding Text, ElementName=MyWindow}"/> Sample 2: <Window DataContext={Binding RelativeSource={RelativeSource Self}}> then the binding is {Binding Text}
The sample is from MSDN <Window.Resources> <c:AsyncDataSource SlowestDP="Slowest Value" SlowerDP="Slower Value" FastDP="Fast Value" x:Key="AsyncDS" /> </Window.Resources> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding Source={StaticResource AsyncDS}}"> <TextBlock FontSize="18" FontWeight="Bold" Margin="10" HorizontalAlignment="Center">Priority Binding</TextBlock> <TextBlock Background="Honeydew" Width="100" HorizontalAlignment="Center"> <TextBlock.Text> <PriorityBinding FallbackValue="defaultvalue"> <Binding Path="SlowestDP" IsAsync="True"/> <Binding Path="SlowerDP" IsAsync="True"/> <Binding Path="FastDP" [Read More ...]
Actually, there is no big different if you want to programmatically click a button in either WPF or Windows Form. They might have slightly different approach. Click: Button1.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); Press: typeof(Button).GetMethod("set_IsPressed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(Button1, new object[] { true }); Unpress: typeof(Button).GetMethod("set_IsPressed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(Button1, new object[] { false }); Other solution is just ButtonAutomationPeer: Please [Read More ...]
You can use either of code behind or XAML to implement data binding in WPF: 1: Code behind binding: There are MultiBinding and Binding (single) 2 types: //binding background color MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = new ViewModels.DeviceIOViewModel.TypeAndStatusToColorConverter(); multiBinding.Bindings.Add(new Binding { Source = DeviceIODataList.DeviceList[this.DeviceIndex], //this.IODataSource, Path = new PropertyPath("DeviceType") }); multiBinding.Bindings.Add(new Binding { Source [Read More ...]
In a multithread WPF project, we got program crash, but actually WPF did not give us any help or error information on the screen, then we tried to debug using steps, finally we got the following error information on a line of code with adding related variable in this line of code into Watch window: [Read More ...]
When you try to use ConfigurationManager in your WPF project, you might can not get it work because there is no related reference by default in WPF project. You have to add the reference manually, check MSDN here, we know we have to add the reference to System.Configuration.dll file. After above step, you can add [Read More ...]
There is no mouse hover event in WPF, The MouseHover function has been split into two parts: MouseEnter and MouseLeave. So we can use them if we need mouse Hover function. private void UserControl_MouseEnter(object sender, MouseEventArgs e) { … } private void UserControl_MouseLeave(object sender, MouseEventArgs e) { … }