Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding Class inside Static Class

$
0
0

Hello,

I have an xml with some tranlations:

<?xml version="1.0" encoding="utf-8"?><Lista>    <Idioma nome="PT">		<Traducao src="Rede" mean="Rede" /><Traducao src="Perfil" mean="Perfil" /><Traducao src="Config" mean="Configuracao" /></Idioma><Idioma nome="EN"><Traducao src="Rede" mean="Network" /><Traducao src="Perfil" mean="Profile" /><Traducao src="Config" mean="Config" /></Idioma></Lista>

My static class:

public static class Traducao
{
    public static List<Idioma> Idiomas { get; set; }

    public static int LinguaSelecionada { get; set; }

    static Traducao()
    {
        Idiomas = new List<Idioma>();

        XmlTextReader reader = new XmlTextReader("traducao.xml");

        while (reader.Read())
        {
            if (reader.GetAttribute("nome") != null)
            {
                Idiomas.Add(new Idioma(reader.GetAttribute("nome")));
            }
        }
    }
}

My other class (Idioma):

public class Idioma
{
    public Dictionary<string, string> Dicionario = new Dictionary<string, string>();

    public string idioma { get; set; }

    public Idioma(string lang)
    {
        idioma = lang;
        CarregaTraducao();
    }

    public void CarregaTraducao()
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("traducao.xml");

        var nodesList = doc.SelectNodes("Lista/Idioma[@nome='" + idioma + "']/Traducao");

        foreach (XmlNode node in nodesList)
        {
            Dicionario.Add(node.Attributes["src"].Value, node.Attributes["mean"].Value);
        }
    }
}

My menu:

How can I put my Buttons Content, Binding for these situation?

I know how to do it with methods, but I'd like to know of how can I do it with Bindind.

Regards, ADAE.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>