DotNetBrowser inside a ScrollViewer cannot scroll in WPF application - wpf

I have a WPF application where I put on several DotNetBrowser.WPF.WPFBrowserView elements inside a ScrollViewer vertically.
My problem is that these are not scrolling when I start scrolling with the ScrollViewer. I know that this is just an embedded separated window (or something like that) but I have to made this able to scroll.
Is there any way to achive this?
Thank you for any help in advance!

You can solve this by handling ScrollChanged event for the ScrollViewer.
Here's quick example:
scrollViewer.ScrollChanged += delegate (object sender, ScrollChangedEventArgs e)
{
browserView.Browser.SetBounds(-(int)e.HorizontalOffset, -(int)e.VerticalOffset, (int)browserView.ActualWidth, (int)browserView.ActualHeight);
};
You can also try to use lightwight mode.
Browser browser = BrowserFactory.Create(BrowserType.LIGHTWEIGHT);
var browserView = new WPFBrowserView(browser);

Related

windows forms application - how to make the tabs in a tab control get full width?

So i'am working with tabControl in windows forms application and i want to make the tabs get full width regardless whether the application window is maximized or not.
When the window isn't maximized everything appears great:
But when the window gets maximized the tabs doesn't get the full width:
Is there any known way to fix this problem?
Thanks in advance
You can achieve this in some way by modifying the ItemSize property as described bellow, else you'd have to draw the tab page selectors yourself.
public Form1()
{
InitializeComponent();
tabControl1.SizeMode = TabSizeMode.Fixed;
tabControl1.ItemSize = new Size((tabControl1.Width / tabControl1.TabPages.Count) - 1, tabControl1.ItemSize.Height);
}
//Hook to form or parent container Resize event, either Resize or ResizeEnd.
private void Form1_ResizeEnd(object sender, EventArgs e)
{
tabControl1.ItemSize = new Size((tabControl1.Width / tabControl1.TabPages.Count) - 1, tabControl1.ItemSize.Height);
}

WPF Ribbon - Hide quick access toolbar

how do you hide Quick Access Toolbar in a WPF's Ribbon?
For Microsoft Ribbon for WPF, you can hide it by using the VisualTreeHelper. On the Loaded event handler, just resize the row containing the Quick Access Toolbar to 0 :
private void RibbonLoaded(object sender, RoutedEventArgs e)
{
Grid child = VisualTreeHelper.GetChild((DependencyObject)sender, 0) as Grid;
if (child != null)
{
child.RowDefinitions[0].Height = new GridLength(0);
}
}
The Quick Access Toolbar is automatically hidden when the Ribbon control is in a RibbonWindow. When it is not, it seems impossible to hide it. I have already worked hours on this issue and was unable to hide it properly.
But there is one simple workaround: Place the Ribbon control inside of a Panel and give it a negative top margin so it will slide outside of the Panel. Set the Panel's ClipToBounds property to true and the QAT will be hidden.
By the way - there are multiple Ribbon implementations for WPF, even by Microsoft themselves ("Fluent Ribbon" and "Microsoft Ribbon for WPF"), so next time you should mention which one you are talking about.
Or if you want it all in the XAML, this works
<ribbon:Ribbon>
<ribbon:Ribbon.Loaded>CollapseQuickAccessToolbar</ribbon:Ribbon.Loaded>
<x:Code>
private void CollapseQuickAccessToolbar(Object sender, RoutedEventArgs e) {
((Grid)VisualTreeHelper.GetChild((DependencyObject)sender, 0)).RowDefinitions[0].Height = new GridLength(0);
}
</x:Code>
</ribbon:Ribbon>
Here is the solution :
this.ribbonControl1.ToolbarLocation = DevExpress.XtraBars.Ribbon.RibbonQuickAccessToolbarLocation.Hidden;
I know this is an old post, but found an easier solution...
Add this inside the ribbon :-
<ribbon:Ribbon.QuickAccessToolBar>
<ribbon:RibbonQuickAccessToolBar Visibility="Collapsed"/>
</ribbon:Ribbon.QuickAccessToolBar>
Bit late to the party.
<my:Ribbon >
<my:Ribbon.ApplicationMenu >
<my:RibbonApplicationMenu Visibility="Collapsed">
</my:RibbonApplicationMenu>
</my:Ribbon.ApplicationMenu>
This will help to hide the quick bar

A few AvalonDock styling questions (WPF)

I'm trying to implement AvalonDock into my application, but I'm having trouble figuring out some of the styling techniques. If someone could please help with the following couple of questions, I would be very grateful:
1) Is there a way to remove the main "Close" button from a DocumentPane and instead place individual buttons on the tabs?
2) I have custom-styled buttons in my application that are placed inside DockableContent elements. As long as the DockableContent is docked, the button uses my custom template, but if a pull the DockablePane that contains the DockableContent out and have it floating, the button loses its template. Is there some trick to getting this to hold?
Thanks in advance for your help!
With regard to #2, that seems to be a problem in AvalonDock. I have a TabControl that loses its styling when its dockable content is floated. When docked, styling is restored.
The workaround is to reset the styling on the StateChanged event.
private void OnDockableContentStateChanged (object sender, RoutedEventArgs e)
{
if (uxDockableContent.State == DockableContentState.DockableWindow)
{
foreach (TabItem tabItem in uxTabControl.Items)
{
tabItem.Style = FindResource ("TabItemStyle") as Style;
}
}
}
I had the best luck getting around this by just downloading the source code, making my changes, and recompiling the DLL.

Silverlight ScrollViewer takes focus when scrollbars are not visible

I'm finding that Silverlight's ScrollViewer will still take focus even when the scrollbars are not visible.
Has anyone else seen this issue? Are there any workarounds that will prevent the ScrollViewer acting as a tabstop when the scrollbars are invisible?
Thanks,
What about:
<ScrollViewer IsTabStop="False" ...
There is a simple solution, at least in Silverilght 4 and up. Listen to the LayoutUpdated event on the ScrollViewer and set the IsTabStop property based on the status of the scrollbars.
For example, if you only are using a vertical scroll bar:
void myScrollViewer_LayoutUpdated(object sender, EventArgs e)
{
//this should only be a tabstop if the scrollbar is visible.
myScrollViewer.IsTabStop =
(myScrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible);
}

Is it possible to avoid Focus on SplitContainer?

The WinForm SplitContainer gets the focus when it's dragged or clicked, while the Splitter does not.
The side-effect of this, is that dragging a SplitContainer bar fires Leave/Validate on other controls, and I need to avoid this.
I already tried setting TabStop and CausesValidation to False, but with no success.
Is there a way to stop the SplitContainer from getting focused? (not a big deal, I can still use the old Splitter, but I lose some nice VS properties...)
Remove the SplitContainer control and replace it manually with Panel and Splitter controls. A little more effort, but a much cleaner outcome.
Try with this code:
//This code will move the focus from the splitContainer to TreeView shortly after moved.
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) {
if(this.splitContainer1.CanFocus) {
this.splitContainer1.ActiveControl = this.treeView1;
}
}
Filini,
The only time that the splitcontainer would have focus is when you are actually moving the splitter. So I would so something like this in your validating and leave events.
private void Button_Leave(object sender, EventArgs e)
{
if(SplitContainer.ContainsFocus)
return;
}
I reproduced your issue and when I added the above it still calls the event of course, but the code execution doesn't occur because the SplitContainer has focus while you are moving the splitter.
Hope that helps.

Resources