Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data Binding

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Data Binding

    I have XAML:
    <Page
    xmlns:local="clr-namespace:FinancialInstrumentSearcher"
    xmlns="http://schemas.microsoft.com/winfx/2...l/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:t="clr-namespace:NinjaTrader.Gui.Tools;assembly=NinjaTrad er.Gui"
    xmlns:editors="http://infragistics.com/Editors"
    Title="LoadXAMLPage" MinHeight="700" MinWidth="900" MaxHeight="700" MaxWidth="900"
    >
    <Grid>
    <TreeView x:Name="myTreeView">
    <TreeView.ItemTemplate>
    <HierarchicalDataTemplate ItemsSource="{Binding Path=instrumentsGroups}">
    <StackPanel Orientation="Horizontal">
    <CheckBox
    Focusable="False"
    IsChecked="{Binding IsChecked}"
    VerticalAlignment="Center"
    />
    <TextBox x:Name="myTextBox" Text="{Binding Name}" />
    </StackPanel>
    </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
    </TreeView>
    </Grid>
    </Page>


    I have cs:
    public class FISWindowTabPage : NTTabPage
    {
    private Button exampleButton;
    TextBox myTextBox;
    TreeViewItem treeViewItem;

    IList<InstrumentList> instrumentsGroups;

    public FISWindowTabPage()
    {
    // the content of the page will go here.
    Content = LoadXaml();

    instrumentsGroups = InstrumentList.All;

    //myTextBox = LogicalTreeHelper.FindLogicalNode(Content as DependencyObject, "myTextBox") as TextBox;
    //myTextBox.Text = "b!";
    //myTextBox.SetBinding(TextBlock.TextProperty, new Binding { Source = nodes, Path = new PropertyPath("Text") });

    }

    ...

    I have learned to change myTextBox.Text.
    How can I use Binding in <HierarchicalDataTemplate ItemsSource="{Binding Path=instrumentsGroups}"> to deploy instrumentsGroups in TreeView with Checkboxes?


    Thank You!
    Last edited by Faizulla Baimet; 04-14-2021, 03:47 PM.

    #2
    Hello Faizulla Baimet,

    Thank you for the post.

    Using data bindings in xaml would be a general C# concept so that would not be something which our documentation/support would have information about. The way that the importable addon uses the xaml makes using bindings difficult as you need to manually configure everything in the C# code as you have shown. The xaml is not compiled so using bindings in the actual xaml is not going to work, it would need set from the C# code like you have show.

    If you are working with a TreeView you can search online for general C# tutorials on how to use that control for further information on populating it from C# code. Populating the control without bindings would be the general suggestion. The other alternative would be to create your item in the external visual studio solution which can use compiled xaml: https://ninjatrader.com/support/help...t_overview.htm (Download Visual Studio Solution for AddOn Development).

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Is there a way and example where dll-build and/or API can be used?

      Comment


        #4
        Hello Faizulla Baimet,

        Could you rephrase the question, I am not certain I understand what you are asking here.

        Are you asking about the addon visual studio solution in the help guide?

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I would like to make my window in VS wpf and transit variables from NT (for instance InstrumentList.All) and vice versa
          Last edited by Faizulla Baimet; 04-09-2021, 10:56 AM.

          Comment


            #6
            Hello Faizulla Baimet,

            I would suggest looking at the sample I mentioned, that will do what you are asking:

            https://ninjatrader.com/support/help...t_overview.htm (Download Visual Studio Solution for AddOn Development).

            You are otherwise already using the addon sample basic and the XAML in that use case is not compiled. You would need to build what you need in C# and then apply it to the xaml like the sample shows. You would generally define a control in the XAML and then reference it by its ID to add items to it or work with it in runtime.

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elliot5, Today, 03:37 AM
            0 responses
            2 views
            0 likes
            Last Post elliot5
            by elliot5
             
            Started by Papercut110, Today, 03:17 AM
            0 responses
            3 views
            0 likes
            Last Post Papercut110  
            Started by max333, Today, 02:22 AM
            2 responses
            6 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by cincai, Today, 12:55 AM
            3 responses
            12 views
            0 likes
            Last Post cincai
            by cincai
             
            Started by cincai, Today, 12:51 AM
            1 response
            11 views
            0 likes
            Last Post s.kinra
            by s.kinra
             
            Working...
            X