Results 1 to 3 of 3

Thread: Active control border

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Active control border

    Guys,

    Is it possible to change the border style of controls when they get focus? Ideally across the board, if not how would I do it for each control?

    I have a Silverlight app that needs to be much more visually accessible than normal and need a much stronger highlight on active controls.

    i need to do something like this for textbox, button, combobox, radiobutton, checkbox etc etc...

    Code:
            public AccessibleTextBlock()
            {
                InitializeComponent();
    
                ContentSimpleText.GotFocus += (o, e) =>
                {
                    ContentBorder.BorderThickness = new Thickness(2);
                    ContentBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
    
                };
    
                ContentSimpleText.LostFocus += (o, e) =>
                {
                    ContentBorder.BorderThickness = new Thickness(0);
                };
    Thanks
    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Active control border

    How about create a style template. Then bind each control to the appropriate style so its all centralized.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Active control border

    Thanks Rob,

    How do I do this? I've tried to add this button style definition into the APP.xaml, but I dont know how to make this onfocus only...

    Code:
        <Application.Resources>
            <local:Datasources x:Key="AppDatasources" />
            <!-- added local reference to SilverlightAccessiblity (self)
            Set Local:datasources
            -->
            
            <Style x:Name="BorderStyle" TargetType="Button">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border BorderBrush="Fuchsia"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    Also, when I then try to apply this style on by button on the xaml I get "The property style was not found in type button"

    <Button Content="press me" Grid.Row="2" style="{StaticResource Borderstyle}">
    <interactivity:Interaction.Behaviors>
    <behaviors:ScrollOnFocusBehavior/>
    </interactivity:Interaction.Behaviors>
    </Button>


    Sorry, I have limited understanding of the fundamentals here. Could you explain where and how I should be pointing the controls to a style template and how I can just affect the onfocused border.

    Thanks
    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width