w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » WPF » Page 1
WPF: How to Hide a modal dialog box without destroying it? (its DialogResult)
This does not deal with the result but see how to return data from a Page PageModal is a Page You use NavigationWindow for the modal part public partial class MainWindow : Window { private PageModal pageModal = new PageModal(); public MainWindow() { InitializeComponent(); } private void btnLaunchModal(object sender, RoutedEventArgs e) { NavigationWindow

Categories : Wpf

AddHandler Lambda Expression
MouseEventHandler has two parameters Object sender and RoutedEventArgs e, so you should try x = Sub(s, e) MeMouseMove(points) y = Sub(s, e) MeMouseDown(points) AddHandler MainGrid.MouseMove, AddressOf x AddHandler MainGrid.MouseLeftButtonDown, AddressOf y

Categories : Wpf

Hit testing for a rectangle with holes in it
This isn't so hard to do "by hand", i.e. just write your own geometry code rather than using built-in stuff. For example, here's some pseudocode: function intersectsWith(Shape s, Rectangle rect): if not s.outerBoundary.itersectsWidth(rect): return false for holeRect in s.innerHoles: if fullyContains(holeRect, rect): return false return true # tests if r1 completely contains r

Categories : Wpf

Does CEF3 supports JAWS and accessibility?
Cef3 is partially jaws compatible. For my WPF application it was not able to read. I tried windows screen reader called Narrator. Narrator is a free screen reader which comes installed by default in Windows. CEF3 works fine with narrator. Narrator is able to read the screen of the application.

Categories : Wpf

How to set a prompt for combobox with mixed items?
I solved this in ugly way. I added a grid, put this combobox in the grid with ZIndex=0. I added extra button to the grid with ZIndex=1. This way I get an overlay. Any time users clicks on the button (combo is initially hidden) I open combobox programatically. When users selects anything from dropdown list of the combobox I hide the prompt button.

Categories : Wpf

Can not access the staticresource from a ResourceDictionary
finally i find the reason: Visit http://stackoverflow.com/a/2679228/2325995 MSDN: Resources in a merged dictionary occupy a location in the resource lookup scope that is just after the scope of the main resource dictionary they are merged into.

Categories : Wpf

Button Click and Command Precedence
No, WPF evaluates OnClick before invoking Execute on a bound command. Depending on what the click handler does; you could invoke it from Execute instead, or raise an event back to the view model, which then raises an event back to the view, which then executes the code. Something like: Code-Behind: public SomeViewClass { public SomeViewClass() { InitializeComponent();

Categories : Wpf

WPF TabControl: Children unloaded when other tab is selected
The solution presented in the original question works if you override the control template based on the default control template of TabControl: - Remove ContentPresenter - Add a Grid named PART_ItemsHolder. No more Unloaded events - no more trouble with the TreeView when it is on a non-selected TabItem.

Categories : Wpf

Applying a ControlTemplate Trigger to a CheckBox in a ListView
You need to remove the DisplayMemberBinding="{Binding Result}" from the GridViewColumn. As you are binding the checkbox to result already, and when you set DisplayMemberBinding property, GridView automatically uses a string representation. <GridViewColumn Width="Auto" Header="Result"> <GridViewColumn.CellTemplate> <DataTemplate>

Categories : Wpf

Retrieve the selected item from the menuitems of a context menu. I am using WPF, MVVM
If you want to know which ContextMenuClass corresponds to the menu item that was clicked, you should modify your CommandParameter setter as follows: <Setter Property="CommandParameter" Value="{Binding}" /> And then change your FilterByCmd from a RelayCommand to a RelayCommand<ContextMenuClass>: FilterByCmd = new RelayCommand<ContextMenuClass>(FilterByMenu, _ => tru

Categories : Wpf

WPF datagrid as user control
How you have written that college class makes it look like each college can only have 1 of each type of student? surely a college would have a whole list of students, and what if you're asked to add more courses? you're going to end up with grids everywhere and a big mess. My suggestion would be to add a StudentType (as an enum) onto your student class. So my enum: public enum TypeOfStudent {

Categories : Wpf

Changes to Observable Collection not updating DataGrid
I believe you are on the right track. the reason your view is not updating when you are changing properties in the collection from the view model, is because while you are making use of ObservableCollection for it to work correctly in the way you are describing, you will need to make sure that the type that you are binding to in the collection implements INotifyProperyChanged. Once you do this, th

Categories : Wpf

Custom WPF Control using Expression Effect dll
Set an DisplayName attribute for property: <Description("Image Color to display"), _ Category("Color Properties"), _ DisplayName("Color Tone")> _ Public Property SourceImageColor00() As ColorToneEffect Get Return DirectCast(Me.GetValue(SourceImageColor00Property), ColorToneEffect) End Get Set(ByVal value As ColorToneEffect) Me.SetValue(SourceImageColor00Property,

Categories : Wpf

Disable closing icon upon the slider's value
There are 2 problems here: First you've declared your own WindowStyle property, this property should be inherited from the Window. Secondly, your Slider should have some Minimum set to a negative value, so that user can slide it to some negative value. Otherwise, all he can do is slide it in range between 0 and the Maximum value: //remove this //public WindowStyle WindowStyle { get; set; } and

Categories : Wpf

What is the good place to add object attribute in XAML?
You should place the property inside the Window-element, like this: <Window x:Class="ClosingWindowAsync.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Closing="MainWindow_Closing" Title="MainWindow" Height="350" Width="525" WindowStyle="SingleBorderWindow"> <Gri

Categories : Wpf

How to make WPF scrollviewer smoother
Ensure that ScrollViewer.CanContentScroll is set to false. <ScrollViewer PanningMode="Both" CanContentScroll=false> <TextBlock FontSize="15" TextWrapping="Wrap"> (a block of random text) </TextBlock> </ScrollViewer> Physical vs. Logical Scrolling Physical scrolling is used to scroll content by a predetermined physical increment, typicall

Categories : Wpf

Apply default Button style to custom Button class
I found the solution. There are two ways to accomplish this. Either one is sufficient. The XAML way: Add the Style attribute to the derived control. This presets the new control's style explicitly to whatever has been defined in the application as the Button style. StaticResource is sufficient for this. If a different Style is specified where the derived control is used, that will replace this i

Categories : Wpf

DataGrid style changes in different computers
Without any other information such as code, OS all I can do is guess. DataGrid has a private variable called _selectionAnchor that is responsible for highlighting the row you clicked. I have a similar issue trying to validate the datagrid row selection and I tracked down to this little friend. That might be what is causing your problem.

Categories : Wpf

WPF Button with Multiple Content
Assign DataContext property of button's parent with the user object then in the click event of a button write following code. private void Button_Click(object sender, RoutedEventArgs e) { Button item = sender as Button; if(item != null) { //you will get user details here by using item.DataContext property User clickedUser = item.DataContext

Categories : Wpf

Access a control created at runtime (WPF)
A control that is created in the designer is added to the namescope for the window/usercontrol/template you have created it in. When you add a control in code behind, it is not added to this scope. Why not? It is relatively expensive to do a look up. By creating it in code you get a reference to the new control anyway. It is expected that you will just keep the reference for when you need it. Th

Categories : Wpf

Filter ObservableCollection when button toggled
You should be binding the WrapPanel's ItemsSource to the car collection rather than updating it manually. To toggle the filter, add this event handler to your toggle button: private void toggleFilter_Checked(object sender, RoutedEventArgs e) { ICollectionView view = CollectionViewSource.GetDefaultView(CarList); if (toggleFilter.IsChecked == true) view.Filter =

Categories : Wpf

WPF paragraph keydown not firing
As far as i can tell, the RichTextBox does not route KeyDown events to the current selected Block/Paragraph, therefore you will have to handle the RTB events, and get the current Paragraph by using the current CaretPosition.

Categories : Wpf

Password Message box in VB
You are able to make your own DialogBoxes. Example: Option Strict On Option Explicit On Option Infer Off Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim pwD As New PasswordDialogBox If pwD.ShowDialog() = Windows.Forms.DialogResult.OK Then MessageBox.Show("The user entered the following password: '" & pwD

Categories : Wpf

What is the proper way to Bind a WPF button click in VB.net
In order to handle the button's click event, if you want to follow MVVM, you need to create an ICommand property on your ViewModel. ICommand is the inteface, so you can do something like this (sorry for C#): public class Message: ICommand { public address { get; set; } public bool CanExecute(Object parameter) { return true; } public void Execute(Object parameter)

Categories : Wpf

Styled WPF ComboBox not showing scroll bars
The problem is your second row of the Grid in the style 3_Column_Cmb is set to Auto <RowDefinition Height="Auto"></RowDefinition> For some reason the ScrollViewer thinks it has unlimited space and doesn't show the scrollbars. A workaround is to eliminate both rows and position the ScrollView via the margin (I chose 30 from the top): <Style x:Key="3_Column_Cmb" TargetType="Co

Categories : Wpf

WPF Binding with RelativeSource Self
The first two are equivalent, and bind to the MyText property of the TextBlock itself. But of course, they don't work, because there is no MyText property on TextBlock. The third binds to the MyText property of the current DataContext Use RelativeSource.Self when you need to bind to a property of the current control.

Categories : Wpf

Set Multibing for text - get and set
I believe the problem may be in the Converter you used for MultiBinding, I've just tried a simple demo and looks like that Converter should be implemented like this: public class TestConverter : IMultiValueConverter { private bool justConvertedBack; object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInf

Categories : Wpf

WPF and Control Templates
http://paulstovell.com/blog/wpf-part-names use teplatesPart attribute in your window then in OnApplyTeplate() get referenc to your parts in template

Categories : Wpf

WPF Button Style with textBlock contentTemplate, how to change textblock foreground colour storyboard
You can animate Foreground.Color of the Button when IsEnabled=False. Also there is no need for ContentTemplate in your Style. You can move ViewBox to ControlTemplate and remove ContentTemplate <ControlTemplate TargetType="{x:Type Button}"> <Border ...> <Viewbox> <ContentPresenter ... /> </Viewbox> </Border> <ControlTempl

Categories : Wpf

How to use style defined in another xaml file inside a style
It turns out I need to do <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MultiSelComboBoxStyle.xaml"></ResourceDictionary> </ResourceDictionary.MergedDictionaries> If needs to use styles from different resource files.

Categories : Wpf

How to attached events on DataGridColumnHeader in Custom DataGrid in code behind?
First, you should be known that each time you change visibility of any control, its 'Loaded' event executes. Here in your case, you're providing handlers to the column headers of the datagrid by finding from visual collection of the DataGrid. So, once you flip Visibility of the column from Visible to Collapsed it'll unload column from datagrid and again, when you make it Visible it loads with d

Categories : Wpf

Access dependency property in ViewModel
if you create "real" UserControls with Dependency Properties you should never to this: this.DataContext = new COM_T002_VM(); this is breaking Datacontext inheritence! what you should do is some sort of relative binding (ElementName or RelativeSource): <UserControl x:Name="myLoggingUc"> ... <!-- you always bind in your UserControl to the DPs! --> <TextBox Text="{Bindi

Categories : Wpf

Using WPF WebBrowser control to render web app built with D3.js framework
Ok, I found the root of the problem and the solution. The problem was, that by default WebBrowser controller loads IE8 engine which is not supported by D3.js framework. The solution is to add a registry key that will force it to use IE9 engine as described here: http://www.wiredprairie.us/blog/index.php/archives/1720

Categories : Wpf

How can RoutedEventArgs.OriginalSource Property be used to identify the specific UIElement that originated the event
If you have set of potential candidates to cross check against, you can simply do the equality check between original source and each potential candidate using == or using .Equals() method of Object. Secondly, in case you want original source to tell it's identity, what you can do is set x:Name on control instance in XAML and then in code you can access Name property to validate it's identity. X

Categories : Wpf

Telerik sort and filter columns not working
If the data disappears in a RadGridView when sorting or filtering, it's usually a problem with the comparison of objects. Switch on all .net exceptions and it should become clear where the exception is being thrown. Debug -> Exceptions -> Common Language Runtime Exceptions = true

Categories : Wpf

Is shape animation possible in WPF?
What you are calling Animations are not Animations. It is simply the Button.Background and Button.Foreground changing colour in response to mouse over events. To give a Button rounded corners, you just need to supply your own ControlTemplate for the Button: <Button Content="Submit" HorizontalAlignment="Center" VerticalAlignment="Center"> <Button.Template> <ControlTempla

Categories : Wpf

How do I set a datagrid column to fill within a datagrid set to fill and layout grid that is autosized?
If it possible use a Width="*" for BrokenGrid. The second solution is set fix width for second DataGrid The difference between "*" and "Auto": "*" - takes all left place (no matter how much element in column needs) "Auto" - takes all left place or less (as much as element in column needs) In your case, DataGrid tells BrokenGrid, that its needs 42.0px (I think i could be some DataGrid bug,

Categories : Wpf

Datagridview header click event with MVVM
I saw this answer on stackoverflow itself. Visit following link. Source - Click here

Categories : Wpf

How to get an icon from a picture and used it as a normal image in XAML
Use MS Paint, open image & crop all the icons and save it in separate folder. Set background of every icon with transparent background color. Now you can use all icons in your application.

Categories : Wpf




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.