Delete Browse Solidworks Document File

1 minute read

Objective

I want to:

Demo Video

Below 🎬 video shows how to Delete Browse Solidworks Document File in Visual Studio 2022.


Update XAML File for UI

  • In this article, we will update button text only.

  • Open “MainWindow.xaml” as shown in below 👇🏻 image.

open-xaml-file

  • Update “MainWindow.xaml” as shown in below 👇🏻 image.

update-xaml-code

  • Please see below 👇🏻 code sample for reference.
<syncfusion:ButtonAdv
    Grid.Row="3"
    Grid.Column="1"
    Grid.ColumnSpan="3"
    Width="200"
    Height="30"
    Command="{Binding ClickCommand}"
    IconHeight="0"
    IconWidth="0"
    Label="Delete Browsed File" />
  • Please see below 👇🏻 image for update UI.

update-button-text-ui


Update MainWindowViewModel

  • In this section, we will update MainWindowViewModel.cs file.

  • Open “MainWindowViewModel.xaml” as shown in below 👇🏻 image.

open-view-model-file

  • Go to “ExecuteClickCommand()” method.

  • Add below 👇🏻 code.

async void ExecuteClickCommand()
{
    // Show busy indicator
    IsBusy = true;

    // Check if we browsed a file
    if (string.IsNullOrEmpty(FilePath))
        return;

    // Check if browsed file exist or not
    if (File.Exists(FilePath) == false)
        return;

    await Task.Run(() =>
    {
        // Delete selected file.
        File.Delete(FilePath);
    });

    // Hide busy indicator
    IsBusy = false;
}
  • Please see below 👇🏻 image for update UI.

add-delete-file-code

Final Result

Now we run the application as shown in below 👇🏻 image.

run-application

Now we are able to browse file in MVVM pattern successfully.

This is it !!!

I hope my efforts will helpful to someone!

If you found anything to add or update, please let me know on my e-mail.

Hope this post helps you to Browse Solidworks Document UI.

If you like the post then please share it with your friends also.

Do let me know by you like this post or not!

Till then, Happy learning!!!

Updated: