Click here to Skip to main content
15,901,505 members
Home / Discussions / C#
   

C#

 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 7:40
Exoskeletor2-Jun-20 7:40 
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
Kris Lantz2-Jun-20 9:13
professionalKris Lantz2-Jun-20 9:13 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 9:24
Exoskeletor2-Jun-20 9:24 
QuestionState machine performance woes in .NET Pin
kalberts2-Jun-20 3:04
kalberts2-Jun-20 3:04 
AnswerRe: State machine performance woes in .NET Pin
kalberts2-Jun-20 3:41
kalberts2-Jun-20 3:41 
GeneralRe: State machine performance woes in .NET Pin
F-ES Sitecore2-Jun-20 4:08
professionalF-ES Sitecore2-Jun-20 4:08 
QuestionProblem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
Member 1467808531-May-20 6:47
Member 1467808531-May-20 6:47 
AnswerRe: Problem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
OriginalGriff31-May-20 20:34
mveOriginalGriff31-May-20 20:34 
QuestionMulti threading in C# Pin
bjwaldo28-May-20 9:21
bjwaldo28-May-20 9:21 
AnswerRe: Multi threading in C# Pin
JudyL_MD28-May-20 10:45
JudyL_MD28-May-20 10:45 
AnswerRe: Multi threading in C# Pin
F-ES Sitecore29-May-20 1:17
professionalF-ES Sitecore29-May-20 1:17 
GeneralRe: Multi threading in C# Pin
bjwaldo30-May-20 7:30
bjwaldo30-May-20 7:30 
QuestionLinq TO SQL - Pass Table Name Pin
Kevin Marois28-May-20 8:57
professionalKevin Marois28-May-20 8:57 
AnswerRe: Linq TO SQL - Pass Table Name Pin
Richard Deeming29-May-20 0:11
mveRichard Deeming29-May-20 0:11 
QuestionC# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 3:16
Ertuğrul ÇİÇEK28-May-20 3:16 
AnswerRe: C# How To Get Version Info Of exe in FTP Pin
Richard MacCutchan28-May-20 3:19
mveRichard MacCutchan28-May-20 3:19 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 3:41
Ertuğrul ÇİÇEK28-May-20 3:41 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Richard MacCutchan28-May-20 3:43
mveRichard MacCutchan28-May-20 3:43 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Richard Deeming28-May-20 3:53
mveRichard Deeming28-May-20 3:53 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
OriginalGriff28-May-20 3:57
mveOriginalGriff28-May-20 3:57 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 6:32
Ertuğrul ÇİÇEK28-May-20 6:32 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Richard Deeming28-May-20 8:32
mveRichard Deeming28-May-20 8:32 
QuestionCreating and Binding UI objects in C# instead of XAML (WPF) Pin
Member 1484454026-May-20 12:04
Member 1484454026-May-20 12:04 
he application that I'm creating has a menu comprised of labels/headers. When you click on a menu item (a xaml Label) a drop down appears with subheaders related to that item. However, I need to make this menu customizable via XML. The idea is this, the XML outlines the header names as well as the subheader names for each menu item.

<MenuHeaders>
    <Header Value="Something">
        <NestedHeader1>NestedHeader1</NestedHeader1>
        <NestedHeader2>NestedHeader2</NestedHeader2>
    </Header>
    <Header Value="Something Else">
        <NestedHeader1>NestedHeader1</NestedHeader1>
        <NestedHeader2>NestedHeader2</NestedHeader2>
    </Header>
</MenuHeaders>

I am able to read the XML using XDocument and bind a Dependency Property to the label context. The problem is that I do not know how many menu items might be in the XML file. I wanted to avoid creating a ton of labels and dependency properties for the label content to bind to. Instead of creating labels in xaml and binding to a property in C#, can I create UI items in C# and populate them with elements from a list at run time? There's some code below of how I'm getting and binding the data to a preexisting label.

C#:

<pre>
 public string HeaderName
 {
      get => (string)GetValue(HeaderNameProperty);
      set => SetValue(HeaderNameProperty, value);
 }

 public static readonly DependencyProperty HeaderNameProperty =
        DependencyProperty.Register("HeaderName", typeof(string), typeof(MainWindow));

 private void LoadHeaders()
{
    var msg = new List<string>(0);
    XDocument doc = null;

    try
    {
        doc = XDocument.Load("MenuHeaders.xml");
    }
    catch (Exception e)
    {
        msg.Add(string.Format("Unable to open file:{0}", ""));
        msg.Add(e.Message);
    }

    if(doc != null)
    {
        var allHeaders = doc.Descendants("Header").ToList();
        List<string> headers = new List<string>();

        foreach(XNode node in allHeaders)
        {
            XElement element = node as XElement;
            foreach(XAttribute attribute in element.Attributes())
            {
                headers.Add(attribute.Value);
            }
        }
        HeaderName = headers[0];
    }
}

XAML:

<stackpanel x:name="Stack">


(As you may have noticed, I'm only adding the Header attributes to the List and none of the subheaders. This code is not complete but it's what I currently have) I will appreciate any help.
AnswerRe: Creating and Binding UI objects in C# instead of XAML (WPF) Pin
Mycroft Holmes26-May-20 12:26
professionalMycroft Holmes26-May-20 12:26 
AnswerRe: Creating and Binding UI objects in C# instead of XAML (WPF) Pin
Richard Deeming27-May-20 1:01
mveRichard Deeming27-May-20 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.