Settings
Loading, Using, Saving Settings
To add settings to your plugin, you need to create a class and add public properties to it.
Then, you need to add a field of this class to your plugin class with the settings
attribute.
This is it, now your settings are read from the settings file for you,
you can access them using the _settings
field, and any changes in them are saved for you when you close Flow Launcher.
Settings UI
Let’s create a simple UI that will let us change the city in our MySettings
class.
Create a UserControl
in your project called MySettingsUi.xaml
in your project and add the following code:
Now, you need to modify MySettingsUi.xaml.cs
.
You’ll accept your MySettings
instance as a parameter of the constructor here
and set it as this control’s DataContext
.
All you have to do now is tell Flow Launcher how to create your settings UI.
You can do this back in Main.cs
with the CreateSettingsUi
attribute.
Now, when you open the settings for your plugin in Flow Launcher, you should see a textbox where you can enter the city name. The settings are ready.