This is a simple example to have an OpenFileDialog (a premade view done by Windows to select a file to open) with WPF, filtering on XLSX file: In this case the InitialDirectory will always exist because it is the Desktop of the current user. But you have to know that if the targeted InitialDirectory doesn’t […]
WPF – Animated Image
It is sometimes interesting to have an animated icon to tell to our user that their command is actually processing. Typically for a refresh icon. So, two solution: you could use an animated GIF and use an external library like WpfAnimatedGif (or the XAML MediaElement), or use an rounded icon (like this one) and create […]
WPF – Animated text
Sometimes it can be useful to have an animated text even in WPF. Typically a “Loading…”, where the 3 dots are moving one by one. Here is a simple way to do an animation with text: <StackPanel Orientation=”Horizontal” Margin=”20″> <Button Content=”Start” Height=”20″ Command=”{Binding StartCommand}” VerticalAlignment=”Top” Margin=”5″ /> <Button Content=”Stop” Height=”20″ Command=”{Binding StopCommand}” VerticalAlignment=”Top” Margin=”5″ /> […]
WPF – Nullable binding
Hello Devz, Imagine you have a TextBox binded to a nullable integer and you put a value in it. Now let’s say you delete this value. You expect to have your value to be null. To be able to do that, you need to update the properties of you binding like this: <TextBox Text=”{Binding Value, […]
WPF – Change color of a row in a DataGrid depending on the value with DataTrigger
Hi folks, Today we will see how to change the color or a row depending on the value of the content. To do that, create a simple View: <Window x:Class=”DataTrigger_Test.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″ xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ mc:Ignorable=”d” Title=”MainWindow” Height=”350″ Width=”525″> <Grid> <DataGrid Margin=”10″ ItemsSource=”{Binding Users}” AutoGenerateColumns=”False” ColumnWidth=”*” HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” HorizontalContentAlignment=”Stretch” EnableRowVirtualization=”false” EnableColumnVirtualization=”false” CanUserAddRows=”False” CanUserReorderColumns=”False” CanUserResizeColumns=”True”> <DataGrid.CellStyle> <Style […]
WPF – DataGrid with single click checkbox
The problem with the checkbox in a WPF DataGrid By default, if you place a checkbox in a WPF DataGrid, you will have to click twice to check or uncheck the checkbox. And there is a logical explanation. The first click will select the row in the DataGrid, and the second one, the checkbox in […]