เน้น RibbonButton สุดท้าย

ฉันจะเน้นปุ่มสุดท้ายที่ถูกคลิกเพื่อให้ผู้ใช้แน่ใจว่าเนื้อหาถูกต้องแสดงได้อย่างไร (ฉันต้องการให้มีปุ่มไฮไลต์ 1 ปุ่มสำหรับเนื้อหาเฉพาะจนกว่าจะมีการคลิกอีกปุ่มหนึ่ง)

ฉันกำลังใช้ Ribbon (System.Windows.Controls.Ribbon) ปุ่มที่ควรไฮไลต์จะอยู่ภายใน RibbonGroup และมีไว้สำหรับเปลี่ยนเนื้อหาหลัก

ปุ่มอื่นๆ ควรทำงานได้ตามปกติ (ฉันต้องการจำกัดจำนวนปุ่มที่ถูกไฮไลต์หลังจากการคลิก)

ฉันใช้รูปแบบ Model-View-ViewModel

    <Ribbon DockPanel.Dock="top">
            <RibbonTab Header="Home">
                <RibbonGroup Header="Process Flow">
                    <StackPanel Orientation="Horizontal">
                        <RibbonButton Label="Style change" LargeImageSource="pack://application:,,,/Resources/StyleChange.png"></RibbonButton>
                        <RibbonButton Label="Settings" Command="{Binding ChangeToSettingContentCommand}" LargeImageSource="pack://application:,,,/Resources/Settings.png"></RibbonButton>
                        <RibbonButton Label="Firmware changes" LargeImageSource="pack://application:,,,/Resources/Code.png"></RibbonButton>
                        <RibbonButton x:Name="testsButton" Label="Tests" Command="{Binding ChangeToTestContentCommand}" LargeImageSource="pack://application:,,,/Resources/test.png"></RibbonButton>
                    </StackPanel>
                </RibbonGroup>

person corso    schedule 27.09.2016    source แหล่งที่มา


คำตอบ (1)


ฉันได้แก้ไขมันด้วยการผูกคุณสมบัติ HighLightSettingButton และ BorderBrush

<RibbonButton Label="Settings" BorderBrush="{Binding HighLightSettingButton, Converter={StaticResource brs}}" Command="{Binding ChangeToSettingContentCommand}" LargeImageSource="pack://application:,,,/Resources/Settings.png"></RibbonButton

และการนำ Border Brush ไปใช้ก็คือ

    public class BrushColorConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
        if ((bool)value == true) {
            return new SolidColorBrush(Colors.Orange);                 
            //return (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFEBAA"));
        } else
        return null;
    }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
        throw new NotImplementedException();
    }

 }
person corso    schedule 18.10.2016