How can I bind a view-model property to a dynamic resource in WPF app?

183 Views Asked by At

I use dynamic resources for localization in my application. It works as expected if I name a resource directly.

<Button Content="{DynamicResource Home}"
              Command="{Binding NavigateHomeCommand}"
              Margin="30 0"/>

Still templates localization needs bindings for view-model properties which seem to be incompatible with dynamic resources. Here's the code example.

<DataTemplate DataType="{x:Type presentation:SideBarItem}"
                  x:Key="OptionsButtonTemplate">
      <Button Command="{Binding NavigateRelatedViewCommand}">
        <Button.Template>
          <ControlTemplate>
            <TextBlock Text="{DynamicResource {Binding Title}}"
                       FontSize="18"/>
          </ControlTemplate>
        </Button.Template>
      </Button>
    </DataTemplate>

Is there a workaround for this case?

0

There are 0 best solutions below