バージョン

Cloned イベント (RadioButtonTool)

ツールがクローンされた後に発生します。
シンタックス
'宣言
 
Public Event Cloned As EventHandler(Of ToolClonedEventArgs)
public event EventHandler<ToolClonedEventArgs> Cloned
イベント データ

イベント ハンドラが、このイベントに関連するデータを含む、ToolClonedEventArgs 型の引数を受け取りました。次の ToolClonedEventArgs プロパティには、このイベントの固有の情報が記載されます。

プロパティ解説
ClonedTool クローンされたツール インスタンスを返します(読み取り専用)
EventHandlersAttached のイベントの送られたイベント ハンドラーが OriginalTool 用の同じイベントに関連付けられているかどうかを示すブール値を返します。
Handled System.Windows.RoutedEventArgsから継承されます。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource System.Windows.RoutedEventArgsから継承されます。Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
OriginalTool クローンされたツール インスタンスを返します(読み取り専用)
RoutedEvent System.Windows.RoutedEventArgsから継承されます。Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source System.Windows.RoutedEventArgsから継承されます。Gets or sets a reference to the object that raised the event.
解説

XamRibbon で追加位置に配置することを有効にするためにツールのクローンが作成される時に発生されます。たとえば、ツールが QuickAccessToolbar に追加されると、XamRibbon はリボン上に表示されるツールのインスタンスのクローンを作成して、QAT 上にクローンが作成されたインスタンスを配置します。このイベントは、クローン作成が行われた後で発生し、クローンが作成されたツールでイベントのためのイベント リスナーをフックする便利な点です。

使用例
Private Sub addRadioButtonToolProperties() 
    If xamRibbon.Tabs.Count < 1 Then 
        Return 
    End If 
    Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0) 
    Dim radioButtonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "RadioButtonToolProperties") 
    
    'Create RadioButtonTool 
    Dim radioButtonTool As New RadioButtonTool() 
    radioButtonTool.Caption = "RadioButton Tool" 
    radioButtonTool.Id = "RadioButton1" 
    radioButtonTool.KeyTip = "RB1" 
    radioButtonTool.LargeImage = getImageSource("/images/icons/Ribbon/Paste_32x32.png") 
    radioButtonTool.SmallImage = getImageSource("/images/icons/Ribbon/Paste_16x16.png") 
    radioButtonTool.IsChecked = True 
    
    radioButtonToolGroup.Items.Add(radioButtonTool) 
    
    AddHandler radioButtonTool.Click, AddressOf radioButtonTool_Click 
    AddHandler radioButtonTool.Cloned, AddressOf radioButtonTool_Cloned 
    AddHandler radioButtonTool.CloneDiscarded, AddressOf radioButtonTool_CloneDiscarded 
End Sub 

'Event Handlers 
Private Sub radioButtonTool_CloneDiscarded(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is cloned discarded!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

Private Sub radioButtonTool_Cloned(ByVal sender As Object, ByVal e As Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is cloned!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

Private Sub radioButtonTool_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) 
    Me.mListBox.Items.Add("" & Chr(10) & "RadioButtonTool " + getSendername(sender) + " is clicked!") 
    mListBox.ScrollIntoView(mListBox.Items(mListBox.Items.Count - 1)) 
End Sub 

'Print RadioButtonTool properties 
Private Function getSendername(ByVal sender As Object) As String 
    Dim result As String = "unknown" 
    
    If TypeOf sender Is RadioButtonTool Then 
        Dim rbtool As RadioButtonTool = TryCast(sender, RadioButtonTool) 
        result = "RadioButtonTool" + ":" + rbtool.Caption + "location:" + rbtool.Location.ToString() 
        result += "" & Chr(10) & "IsActine=" + rbtool.IsActive.ToString() + ",IsOnQat=" + rbtool.IsOnQat.ToString() 
        result += "" & Chr(10) & "HaImage=" + rbtool.HasImage.ToString() + ",IsQatCommonTool=" + rbtool.IsQatCommonTool.ToString() 
        result += "" & Chr(10) & "SizingMode=" + rbtool.SizingMode.ToString() + ",KeyTip=" + rbtool.KeyTip 
        result += "" & Chr(10) & "HasCaption=" + rbtool.HasCaption.ToString() + ",Id=" + rbtool.Id 
        result += "" & Chr(10) & "IsChecked=" + rbtool.IsChecked.ToString() 
        result += "" & Chr(10) & "LargeImage=" + rbtool.LargeImage.ToString() 
        result += "" & Chr(10) & "SmallImage=" + rbtool.SmallImage.ToString() 
    End If 
    
    Return result 
End Function 

'Create RibbonGroup 
Private Function getRibbonGroup(ByVal igTabItem As RibbonTabItem, ByVal ribbonGroupCaption As String) As RibbonGroup 
    Dim ribbonGroup As New RibbonGroup() 
    ribbonGroup.Caption = ribbonGroupCaption 
    Dim toolHorizontalWrapPanel As New ToolHorizontalWrapPanel() 
    ribbonGroup.Items.Add(toolHorizontalWrapPanel) 
    igTabItem.RibbonGroups.Add(ribbonGroup) 
    Return ribbonGroup 
End Function
private void addRadioButtonToolProperties()
{
	if (xamRibbon.Tabs.Count < 1) { return; }
	RibbonTabItem igrTabItem = xamRibbon.Tabs[0];
	RibbonGroup radioButtonToolGroup = getRibbonGroup(igrTabItem, "RadioButtonToolProperties");

	//Create RadioButtonTool
	RadioButtonTool radioButtonTool = new RadioButtonTool();
	radioButtonTool.Caption = "RadioButton Tool";
	radioButtonTool.Id = "RadioButton1";
	radioButtonTool.KeyTip = "RB1";
	radioButtonTool.LargeImage = getImageSource("/images/icons/Ribbon/Paste_32x32.png");
	radioButtonTool.SmallImage = getImageSource("/images/icons/Ribbon/Paste_16x16.png");
	radioButtonTool.IsChecked = true;

	radioButtonToolGroup.Items.Add(radioButtonTool);

	radioButtonTool.Click += new RoutedEventHandler(radioButtonTool_Click);
	radioButtonTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(radioButtonTool_Cloned);
	radioButtonTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(radioButtonTool_CloneDiscarded);
}

//Event Handlers
void radioButtonTool_CloneDiscarded(object sender, Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is cloned discarded!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void radioButtonTool_Cloned(object sender, Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is cloned!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

void radioButtonTool_Click(object sender, RoutedEventArgs e)
{
	this.mListBox.Items.Add("\nRadioButtonTool " + getSendername(sender) + " is clicked!");
	mListBox.ScrollIntoView(mListBox.Items[mListBox.Items.Count - 1]);
}

//Print RadioButtonTool properties
private string getSendername(object sender)
{
    string result = "unknown";

	if (sender is RadioButtonTool)
	{
		RadioButtonTool rbtool = sender as RadioButtonTool;
		result = "RadioButtonTool" + ":" + rbtool.Caption + "location:" + rbtool.Location.ToString();
		result += "\nIsActine=" + rbtool.IsActive.ToString() + ",IsOnQat=" + rbtool.IsOnQat.ToString();
		result += "\nHaImage=" + rbtool.HasImage.ToString() + ",IsQatCommonTool=" + rbtool.IsQatCommonTool.ToString();
		result += "\nSizingMode=" + rbtool.SizingMode.ToString() + ",KeyTip=" + rbtool.KeyTip;
		result += "\nHasCaption=" + rbtool.HasCaption.ToString() + ",Id=" + rbtool.Id;
		result += "\nIsChecked=" + rbtool.IsChecked.ToString();
		result += "\nLargeImage=" + rbtool.LargeImage.ToString();
		result += "\nSmallImage=" + rbtool.SmallImage.ToString();
	}
			
	return result;
}

//Create RibbonGroup
private RibbonGroup getRibbonGroup(RibbonTabItem igTabItem, string ribbonGroupCaption)
{
	RibbonGroup ribbonGroup = new RibbonGroup();
	ribbonGroup.Caption = ribbonGroupCaption;
	ToolHorizontalWrapPanel toolHorizontalWrapPanel = new ToolHorizontalWrapPanel();
	ribbonGroup.Items.Add(toolHorizontalWrapPanel);
	igTabItem.RibbonGroups.Add(ribbonGroup);
	return ribbonGroup;
}
<!--RadioButtonTool-->
<igRibbon:RadioButtonTool Name="boldTool" Id="boldToolId" KeyTip="TB1"
    
LargeImage="Images\icons\Ribbon\Bold.png" 
    
SmallImage="Images\icons\Ribbon\Bold.png" 
    
Click="boldTool_Click" IsChecked="True"
    
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"
    
igRibbon:RibbonGroup.MinimumSize="ImageOnly" />
<!--RadioButtonTool-end-->


private void boldTool_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("boldTool is clicked!");
}
参照