Articles in this section
Category / Section

How to change the border style based on the value of skinstorage visualstyle?

1 min read

In general, the VisualStyle can be applied dynamically to the application. While changing the VisualStyle value, you can perform other operations. The following code example demonstrates how to change the Border background based on the value of SkinStorage.VisualStyle. In the example, the ComboBox is populated with the visual style values like Metro, Office2010Blue, and Office2010Silver. When you choose a style from the ComboBox, the border background is changed based on the selected style.

XAML

      <Window.Resources>
        <LinearGradientBrush x:Key="Office2010BlueGradientColor" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Offset="0.0" Color="#FFAFCDF5" />
            <GradientStop Offset="0.5" Color="#FF8CB0DF" />
            <GradientStop Offset="1.0" Color="#FF729ACE" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="Office2010SilverGradientColor" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Offset="0.0" Color="#FFA2A6AE" />
            <GradientStop Offset="0.5" Color="#FFC8CCD1" />
            <GradientStop Offset="1.0" Color="#FFC2C6CA" />
        </LinearGradientBrush>
        <Style TargetType="{x:Type Border}">
            <Setter Property="BorderBrush" Value="#FFCCCCCC"></Setter>
            <Setter Property="BorderThickness" Value="2"></Setter>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Text, ElementName=ListOfStyles}" Value="Metro">
                    <Setter Property="Background" Value="#FF119EDA"></Setter>
                    <Setter Property="BorderBrush" Value="#FF119EDA"></Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding Text, ElementName=ListOfStyles}"  Value="Office2010Blue">
                    <Setter Property="Background" Value="{StaticResource Office2010BlueGradientColor}"></Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding Text, ElementName=ListOfStyles}"  Value="Office2010Silver">
                    <Setter Property="Background" Value="{StaticResource Office2010SilverGradientColor}"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <StackPanel>
            <Border Height="Auto" Width="Auto"  >
                <TextBlock Text="Policyholder Summary" FontWeight="Bold" Margin="10,10" ></TextBlock>
            </Border>
            <ComboBox x:Name="ListOfStyles" Height="30" Width="200"  >
                </ComboBox>
          </StackPanel>
    </Grid>

 

C#

   private List<string> source = new List<string>();
        public MainWindow()
        {
            InitializeComponent();
            source.Add("Metro");
            source.Add("Office2010Blue");
            source.Add("Office2010Silver");
            ListOfStyles.ItemsSource = source;
            ListOfStyles.SelectedIndex = 0;
        }

 

The following screenshots are the output of the code above:

Metro Visual Style in WPF

Figure 1: Metro Visual Style

Office2010Blue Visual Style in WPF

Figure 2: Office2010Blue Visual Style

                                                               

Office2010Silver Visual Style in WPF

Figure 3: Office2010Silver Visual Style

 

 

Conclusion

I hope you enjoyed learning about how to change the border style based on the value of skinstorage visualstyle.

You can refer to our WPF feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied