Obtain ListBox SelectedItem through ContextMenu with Multibinding in Windows.ResourceHow to loop through all enum values in C#?Styling a ListBoxItem depending on its index in the ListBoxBind SelectedItem in a ListBox to CommandParameter in a ContextMenuBinding to the UserControl which contains the ItemControl dataAdding image to ListBox itemRelativeSource binding not resolvingBinding between two controls declared in the same WPF ContextMenu MenuItemSelected Item of TreeviewWPF create a ListView with ContextMenu inside a WebBrowser using ICommandWPF ContextMenu: MenuItem Icon visibility binding error

Unsolved Problems (Not Independent of ZFC) due to Lack of Computational Power

Default camera device to show screen instead of physical camera

Symlink to directory for easy access: .bashrc, usr/local/bin, something else?

Moons that can't see each other

Why doesn't the Falcon-9 first stage use three legs to land?

Do living authors still get paid royalties for their old work?

Have only girls been born for a long time in this village?

Multicolumn in table not centered

Is there any road between the CA State Route 120 and Sherman Pass Road (Forest Route 22S0) that crosses Yosemite/Serria/Sequoia National Park/Forest?

Syncing bitcoin node with multiple cores

Did Wernher von Braun really have a "Saturn V painted as the V2"?

What happened after the end of the Truman Show?

How could Tony Stark wield the Infinity Nano Gauntlet - at all?

Chess software to analyze games

Can 'in-' mean both 'in' and 'no'?

Land Registry Clause

Sous vide chicken without an internal tempature of 165

Gofer work in exchange for Letter of Recommendation

Use of vor in this sentence

How do you call it when two celestial bodies come as close to each other as they will in their current orbits?

What is the evidence on the danger of feeding whole blueberries and grapes to infants and toddlers?

What can I do to keep a threaded bolt from falling out of it’s slot

Does banks' profitability really suffer under low interest rates

"Silverware", "Tableware", and "Dishes"



Obtain ListBox SelectedItem through ContextMenu with Multibinding in Windows.Resource


How to loop through all enum values in C#?Styling a ListBoxItem depending on its index in the ListBoxBind SelectedItem in a ListBox to CommandParameter in a ContextMenuBinding to the UserControl which contains the ItemControl dataAdding image to ListBox itemRelativeSource binding not resolvingBinding between two controls declared in the same WPF ContextMenu MenuItemSelected Item of TreeviewWPF create a ListView with ContextMenu inside a WebBrowser using ICommandWPF ContextMenu: MenuItem Icon visibility binding error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm trying to use multibinding on a context menu stored in Window.Resources and I can't figure out how to get the SelectedItem of the ListBox I attach the menu to.



I think I need to use PlacementTarget, but can't get anything to work. I tried using FindAncestor, but that didn't work. I also tried getting the listbox by the ElementName to no avail.



<Window ...>
<Window.DataContext>
<local:IPViewModel/>
</Window.DataContext>
<Window.Resources>
<sys:Int32 x:Key="Number">0</sys:Int32>
<sys:Int32 x:Key="NumberLetter">1</sys:Int32>
<sys:Int32 x:Key="NumberLetterNumber">2</sys:Int32>

<local:CombineParams x:Key="CombineParams"/>

<ContextMenu x:Key="DetailMenu">
<MenuItem Header = "Number">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="Binding SwitchLabelMode">
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="StaticResource CombineParams">
<!-- The next line is where I'm not sure what to write to get to the listbox -->
<Binding Source="RelativeSource AncestorType=x:Type ListBox"/>
<Binding Source="StaticResource Number"/>
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</MenuItem>
...
</Window.Resources>

...
<ListBox Name="IndexDetailsListBox"
...
ContextMenu="StaticResource DetailMenu"
...>

</ListBox>
...
</Window>


I can't get it to give back anything other than unset value.
I'm grateful for any help. None of the other questions I found have the contextmenu in Window.Resources with MultiBinding which seems to be my issue.










share|improve this question






























    2















    I'm trying to use multibinding on a context menu stored in Window.Resources and I can't figure out how to get the SelectedItem of the ListBox I attach the menu to.



    I think I need to use PlacementTarget, but can't get anything to work. I tried using FindAncestor, but that didn't work. I also tried getting the listbox by the ElementName to no avail.



    <Window ...>
    <Window.DataContext>
    <local:IPViewModel/>
    </Window.DataContext>
    <Window.Resources>
    <sys:Int32 x:Key="Number">0</sys:Int32>
    <sys:Int32 x:Key="NumberLetter">1</sys:Int32>
    <sys:Int32 x:Key="NumberLetterNumber">2</sys:Int32>

    <local:CombineParams x:Key="CombineParams"/>

    <ContextMenu x:Key="DetailMenu">
    <MenuItem Header = "Number">
    <i:Interaction.Triggers>
    <i:EventTrigger EventName="Click">
    <i:InvokeCommandAction Command="Binding SwitchLabelMode">
    <i:InvokeCommandAction.CommandParameter>
    <MultiBinding Converter="StaticResource CombineParams">
    <!-- The next line is where I'm not sure what to write to get to the listbox -->
    <Binding Source="RelativeSource AncestorType=x:Type ListBox"/>
    <Binding Source="StaticResource Number"/>
    </MultiBinding>
    </i:InvokeCommandAction.CommandParameter>
    </i:InvokeCommandAction>
    </i:EventTrigger>
    </i:Interaction.Triggers>
    </MenuItem>
    ...
    </Window.Resources>

    ...
    <ListBox Name="IndexDetailsListBox"
    ...
    ContextMenu="StaticResource DetailMenu"
    ...>

    </ListBox>
    ...
    </Window>


    I can't get it to give back anything other than unset value.
    I'm grateful for any help. None of the other questions I found have the contextmenu in Window.Resources with MultiBinding which seems to be my issue.










    share|improve this question


























      2












      2








      2








      I'm trying to use multibinding on a context menu stored in Window.Resources and I can't figure out how to get the SelectedItem of the ListBox I attach the menu to.



      I think I need to use PlacementTarget, but can't get anything to work. I tried using FindAncestor, but that didn't work. I also tried getting the listbox by the ElementName to no avail.



      <Window ...>
      <Window.DataContext>
      <local:IPViewModel/>
      </Window.DataContext>
      <Window.Resources>
      <sys:Int32 x:Key="Number">0</sys:Int32>
      <sys:Int32 x:Key="NumberLetter">1</sys:Int32>
      <sys:Int32 x:Key="NumberLetterNumber">2</sys:Int32>

      <local:CombineParams x:Key="CombineParams"/>

      <ContextMenu x:Key="DetailMenu">
      <MenuItem Header = "Number">
      <i:Interaction.Triggers>
      <i:EventTrigger EventName="Click">
      <i:InvokeCommandAction Command="Binding SwitchLabelMode">
      <i:InvokeCommandAction.CommandParameter>
      <MultiBinding Converter="StaticResource CombineParams">
      <!-- The next line is where I'm not sure what to write to get to the listbox -->
      <Binding Source="RelativeSource AncestorType=x:Type ListBox"/>
      <Binding Source="StaticResource Number"/>
      </MultiBinding>
      </i:InvokeCommandAction.CommandParameter>
      </i:InvokeCommandAction>
      </i:EventTrigger>
      </i:Interaction.Triggers>
      </MenuItem>
      ...
      </Window.Resources>

      ...
      <ListBox Name="IndexDetailsListBox"
      ...
      ContextMenu="StaticResource DetailMenu"
      ...>

      </ListBox>
      ...
      </Window>


      I can't get it to give back anything other than unset value.
      I'm grateful for any help. None of the other questions I found have the contextmenu in Window.Resources with MultiBinding which seems to be my issue.










      share|improve this question














      I'm trying to use multibinding on a context menu stored in Window.Resources and I can't figure out how to get the SelectedItem of the ListBox I attach the menu to.



      I think I need to use PlacementTarget, but can't get anything to work. I tried using FindAncestor, but that didn't work. I also tried getting the listbox by the ElementName to no avail.



      <Window ...>
      <Window.DataContext>
      <local:IPViewModel/>
      </Window.DataContext>
      <Window.Resources>
      <sys:Int32 x:Key="Number">0</sys:Int32>
      <sys:Int32 x:Key="NumberLetter">1</sys:Int32>
      <sys:Int32 x:Key="NumberLetterNumber">2</sys:Int32>

      <local:CombineParams x:Key="CombineParams"/>

      <ContextMenu x:Key="DetailMenu">
      <MenuItem Header = "Number">
      <i:Interaction.Triggers>
      <i:EventTrigger EventName="Click">
      <i:InvokeCommandAction Command="Binding SwitchLabelMode">
      <i:InvokeCommandAction.CommandParameter>
      <MultiBinding Converter="StaticResource CombineParams">
      <!-- The next line is where I'm not sure what to write to get to the listbox -->
      <Binding Source="RelativeSource AncestorType=x:Type ListBox"/>
      <Binding Source="StaticResource Number"/>
      </MultiBinding>
      </i:InvokeCommandAction.CommandParameter>
      </i:InvokeCommandAction>
      </i:EventTrigger>
      </i:Interaction.Triggers>
      </MenuItem>
      ...
      </Window.Resources>

      ...
      <ListBox Name="IndexDetailsListBox"
      ...
      ContextMenu="StaticResource DetailMenu"
      ...>

      </ListBox>
      ...
      </Window>


      I can't get it to give back anything other than unset value.
      I'm grateful for any help. None of the other questions I found have the contextmenu in Window.Resources with MultiBinding which seems to be my issue.







      c# .net wpf xaml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 14:11









      user10891785user10891785

      133 bronze badges




      133 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          2














          Your problem is, that you assign RelativeSource- object to the Source property of the Binding object. RelativeSource- object belongs to the RelativeSource-property.

          So you get your List to the multi value converter:



          <MultiBinding Converter="StaticResource CombineParams">
          <Binding Path="PlacementTarget" RelativeSource="RelativeSource AncestorType=x:Type ContextMenu"/>
          <Binding Source="StaticResource Number"/>
          </MultiBinding>





          share|improve this answer




















          • 1





            That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

            – user10891785
            Mar 27 at 14:51






          • 1





            You are welcome! :)

            – Rekshino
            Mar 27 at 14:53










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55379343%2fobtain-listbox-selecteditem-through-contextmenu-with-multibinding-in-windows-res%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Your problem is, that you assign RelativeSource- object to the Source property of the Binding object. RelativeSource- object belongs to the RelativeSource-property.

          So you get your List to the multi value converter:



          <MultiBinding Converter="StaticResource CombineParams">
          <Binding Path="PlacementTarget" RelativeSource="RelativeSource AncestorType=x:Type ContextMenu"/>
          <Binding Source="StaticResource Number"/>
          </MultiBinding>





          share|improve this answer




















          • 1





            That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

            – user10891785
            Mar 27 at 14:51






          • 1





            You are welcome! :)

            – Rekshino
            Mar 27 at 14:53















          2














          Your problem is, that you assign RelativeSource- object to the Source property of the Binding object. RelativeSource- object belongs to the RelativeSource-property.

          So you get your List to the multi value converter:



          <MultiBinding Converter="StaticResource CombineParams">
          <Binding Path="PlacementTarget" RelativeSource="RelativeSource AncestorType=x:Type ContextMenu"/>
          <Binding Source="StaticResource Number"/>
          </MultiBinding>





          share|improve this answer




















          • 1





            That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

            – user10891785
            Mar 27 at 14:51






          • 1





            You are welcome! :)

            – Rekshino
            Mar 27 at 14:53













          2












          2








          2







          Your problem is, that you assign RelativeSource- object to the Source property of the Binding object. RelativeSource- object belongs to the RelativeSource-property.

          So you get your List to the multi value converter:



          <MultiBinding Converter="StaticResource CombineParams">
          <Binding Path="PlacementTarget" RelativeSource="RelativeSource AncestorType=x:Type ContextMenu"/>
          <Binding Source="StaticResource Number"/>
          </MultiBinding>





          share|improve this answer













          Your problem is, that you assign RelativeSource- object to the Source property of the Binding object. RelativeSource- object belongs to the RelativeSource-property.

          So you get your List to the multi value converter:



          <MultiBinding Converter="StaticResource CombineParams">
          <Binding Path="PlacementTarget" RelativeSource="RelativeSource AncestorType=x:Type ContextMenu"/>
          <Binding Source="StaticResource Number"/>
          </MultiBinding>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 14:43









          RekshinoRekshino

          3,3642 gold badges10 silver badges36 bronze badges




          3,3642 gold badges10 silver badges36 bronze badges










          • 1





            That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

            – user10891785
            Mar 27 at 14:51






          • 1





            You are welcome! :)

            – Rekshino
            Mar 27 at 14:53












          • 1





            That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

            – user10891785
            Mar 27 at 14:51






          • 1





            You are welcome! :)

            – Rekshino
            Mar 27 at 14:53







          1




          1





          That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

          – user10891785
          Mar 27 at 14:51





          That works perfectly. Thank you so much. I'd upvote you but it won't let me under 15 reputation.

          – user10891785
          Mar 27 at 14:51




          1




          1





          You are welcome! :)

          – Rekshino
          Mar 27 at 14:53





          You are welcome! :)

          – Rekshino
          Mar 27 at 14:53








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55379343%2fobtain-listbox-selecteditem-through-contextmenu-with-multibinding-in-windows-res%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해