バージョン

SizingMode プロパティ (ToggleButtonTool)

ツールの現在のサイズを示す列挙体を返します。(読み取り専用)
シンタックス
'宣言
 
Public ReadOnly Property SizingMode As RibbonToolSizingMode
public RibbonToolSizingMode SizingMode {get;}
解説

可能なサイズは次を含みます: ImageOnly、ImageAndTextNormal、ImageAndTextLarge。

使用例
Private xamRibbon As XamRibbon
Private mListBox As ListBox
Private Sub addToggleButtonToolProperties()
'Code to Create XamRibbon object..

    If xamRibbon.Tabs.Count < 1 Then
        Return
    End If
    Dim igrTabItem As RibbonTabItem = xamRibbon.Tabs(0)
    'add RibbonGroup
    Dim toggleButtonToolGroup As RibbonGroup = getRibbonGroup(igrTabItem, "ToggleButtonToolProperties")
    'Add ToggleButtonTool
    Dim toggleBtnTool As New ToggleButtonTool()
    toggleBtnTool.Caption = "Toggle Button"
    toggleBtnTool.Id = "ToggleButton1"
    toggleBtnTool.KeyTip = "TG1"
    toggleBtnTool.LargeImage = getImageSource("/images/icons/Ribbon/New_Large.png")
    toggleBtnTool.SmallImage = getImageSource("/images/icons/Ribbon/Open_Large.png")
    toggleBtnTool.IsChecked = True
    AddHandler toggleBtnTool.Click, AddressOf toggleBtnTool_Click
    AddHandler toggleBtnTool.Cloned, AddressOf toggleBtnTool_Cloned
    AddHandler toggleBtnTool.CloneDiscarded, AddressOf toggleBtnTool_CloneDiscarded
    toggleButtonToolGroup.Items.Add(toggleBtnTool)
End Sub

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

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

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


Private Function getSendername(ByVal sender As Object) As String
    Dim result As String = "unknown"
   
    If TypeOf sender Is ToggleButtonTool Then
        Dim tbtool As ToggleButtonTool = TryCast(sender, ToggleButtonTool)
        result = "ToggleButtonTool" + ":" + tbtool.Caption + "location:" + tbtool.Location.ToString()
        result += "" & Chr(10) & "IsActine=" + tbtool.IsActive.ToString() + ",IsOnQat=" + tbtool.IsOnQat.ToString()
        result += "" & Chr(10) & "HaImage=" + tbtool.HasImage.ToString() + ",IsQatCommonTool=" + tbtool.IsQatCommonTool.ToString()
        result += "" & Chr(10) & "SizingMode=" + tbtool.SizingMode.ToString() + ",KeyTip=" + tbtool.KeyTip
        result += "" & Chr(10) & "HasCaption=" + tbtool.HasCaption.ToString() + ",Id=" + tbtool.Id
        result += "" & Chr(10) & "IsChecked=" + tbtool.IsChecked.ToString()
        result += "" & Chr(10) & "LargeImage=" + tbtool.LargeImage.ToString()
        result += "" & Chr(10) & "SmallImage=" + tbtool.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
<!--ToggleButtonTol-->
<igRibbon:ToggleButtonTool Name="boldTool" Id="boldToolId" KeyTip="TB1"
    
LargeImage="Images\icons\Ribbon\Bold.png" 
    
SmallImage="Images\icons\Ribbon\Bold.png" 
    
Click="boldTool_Click"
    
igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge"
    
igRibbon:RibbonGroup.MinimumSize="ImageOnly" />
<!--ToggleButtonTol-end-->


private void boldTool_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("boldTool is clicked!");
}
XamRibbon xamRibbon;
//Code to Create XamRibbon object..
ListBox mListBox;

private void addToggleButtonToolProperties()
{
	if (xamRibbon.Tabs.Count < 1) { return; }
	RibbonTabItem igrTabItem = xamRibbon.Tabs[0];
	//add RibbonGroup
	RibbonGroup toggleButtonToolGroup = getRibbonGroup(igrTabItem, "ToggleButtonToolProperties");
	//Add ToggleButtonTool
	ToggleButtonTool toggleBtnTool = new ToggleButtonTool();
	toggleBtnTool.Caption = "Toggle Button";
	toggleBtnTool.Id = "ToggleButton1";
	toggleBtnTool.KeyTip = "TG1";
	toggleBtnTool.LargeImage = getImageSource("/images/icons/Ribbon/New_Large.png");
	toggleBtnTool.SmallImage = getImageSource("/images/icons/Ribbon/Open_Large.png");
	toggleBtnTool.IsChecked = true;
	toggleBtnTool.Click += new RoutedEventHandler(toggleBtnTool_Click);
	toggleBtnTool.Cloned += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolClonedEventArgs>(toggleBtnTool_Cloned);
	toggleBtnTool.CloneDiscarded += new EventHandler<Infragistics.Windows.Ribbon.Events.ToolCloneDiscardedEventArgs>(toggleBtnTool_CloneDiscarded);
	toggleButtonToolGroup.Items.Add(toggleBtnTool);
}

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

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

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


 private string getSendername(object sender)
{
    string result = "unknown";

    if (sender is ToggleButtonTool)
    {
        ToggleButtonTool tbtool = sender as ToggleButtonTool;
        result = "ToggleButtonTool" + ":" + tbtool.Caption + "location:" + tbtool.Location.ToString();
        result += "\nIsActine=" + tbtool.IsActive.ToString() + ",IsOnQat=" + tbtool.IsOnQat.ToString();
        result += "\nHaImage=" + tbtool.HasImage.ToString() + ",IsQatCommonTool=" + tbtool.IsQatCommonTool.ToString();
        result += "\nSizingMode=" + tbtool.SizingMode.ToString() + ",KeyTip=" + tbtool.KeyTip;
        result += "\nHasCaption=" + tbtool.HasCaption.ToString() + ",Id=" + tbtool.Id;
        result += "\nIsChecked=" + tbtool.IsChecked.ToString();
        result += "\nLargeImage=" + tbtool.LargeImage.ToString();
        result += "\nSmallImage=" + tbtool.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;
}
参照