Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 jclose, Today, 09:37 PM
            0 responses
            4 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,413 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            9 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            10 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            169 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X