Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. Setting the target of a command binding

Setting the target of a command binding

Scheduled Pinned Locked Moved WPF
wpfcsharphtmlwcfcom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dani kenan
    wrote on last edited by
    #1

    Hi, I have a wpf rich text box that I open and show in a win32 application. I declare the rtf box in a resource dictionary like so:

    <RichTextBox
    x:Key="rtfBox"
    HorizontalScrollBarVisibility="Auto"
    VerticalScrollBarVisibility="Auto"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    />

    In another place, I have a wpf window which I use as a floating tool bar. I declare it in its own xaml, similar to the following:

    <Window x:Class="BidiFix.SandBox.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d"
    Title="Window1" AllowsTransparency="True" Focusable="False" ShowActivated="False" ShowInTaskbar="False"
    SizeToContent="Width" Height="24" Topmost="True" Padding="2"
    WindowStyle="None" Background="Transparent" >

    <Border>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="2">
    <Button Command="Copy" Context="Copy"/>
    <Button Command="Cut" Context="Cut"/>
    <Button Command="Paste" Context="Paste"/>
    </StackPanel>
    </Border>
    </Window>

    I instantiate and show the window using the following code:

    RichTextBox rtfBox = GetTheBox();
    Window1 win = new Window1();
    win.Show();

    Now, as you can see I have both the rtf box and window available. But the window is not an ancestor of the rtfBox, nor do they share the same xaml. What minimal markup and/or code is needed to connect the Clipboard commands and button states to the rtf box, such that they will reflect their availability based on the selection state in the rich text box and when click will operate on the rich text box. Please help. 10x.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups