Databinding combobox selected item to settings

I store user specified settings using application settings properties and databinding. It has been working fine, until i want user selected to font for combobox. Databinding between user settings and combobox not working. I want to store font family name.

App.XML
<Application.Resources>
    <ResourceDictionary>
        <properties:Settings x:Key="Settings" />
    </ResourceDictionary>               
</Application.Resources>

Window.XML

<ComboBox Name="Families" ItemsSource="{x:Static Fonts.SystemFontFamilies}"
  <!-- This line -->
  SelectedItem="{Binding Source={StaticResource Settings}, Path=Default.Font, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
              Margin="57,122,199,118">
        <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" FontFamily="{Binding}"/>
        </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

Settings: font String User Arial

Answers


In what way isn't it working? Is an exception thrown, is the project not compiling, or is the setting is not getting saved?

Don't forget that you must expressly save settings once they are modified. For this reason, you might do better to bind to an ICommand that applies and saves the setting, rather than to the setting directly, or add a "save" button that is bound to such a command.


Adding SelectedValuePath="Source" solve this problem.


Need Your Help

jqplot image below plot curve

javascript graph gradient jqplot

What I want is to get a rainbow gradient(VIBYOR) to appear in the area below curve of my plot.

send bulk sms from database

php mysql database sms

I've been trying to use the code below to send sms but it does not send when I loop. It only works if I just pick one number from database. I have over 5,000 numbers in the database and wish to se...