Alex F
Alex F

Reputation: 43331

Using code constant in XAML

I have this XAML code:

<ListBox DataContext="{Binding Tables[Suppliers]}" ItemsSource="{Binding}">
</ListBox>

In the project I have the following code:

namespace Suppliers
{
    class DBServer
    {
        public const string TableSuppliers = "Suppliers";
    }

How can I use Suppliers.DBServer.TableSuppliers in the XAML page instead of hard-coded Suppliers:

{Binding Tables[ ??? ]} 

Upvotes: 1

Views: 1088

Answers (1)

kubal5003
kubal5003

Reputation: 7254

If this what is inside [] is a string you can always use a constant like {x:Static c:Constants.X}

Upvotes: 1

Related Questions