How to hide Grid border - wpf

I have a grid with some controls inside. I want to hide the grid border.
Are there any specific properties which can be used to hide the grid border in WPF?

Set DataGrid.BorderThickness to 0.

I know this is a bit late to add to the thread but incase anyone else stumbles on this question this worked for me:
<Grid ShowGridLines="False">

I too had a similar problem of getting dotted border around a part(Grid) of user control, only when focus is being set to the Grid and solved the problem using;
void Grid_GotFocus (object sender, RoutedEventArgs e) {
Grid.FocusVisualStyle = null;
}
Hope it helps someone :)

Related

DotNetBrowser inside a ScrollViewer cannot scroll in WPF application

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);

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

WPF Datagrid Edit won't allow me to change other cells

I've a Datagrid whose DataContext is assigned to a Dataview. When I try to edit the datagrid shown in the form there appears a red border around the cell being editted AFTER I click out or press Enter.
I then try double clicking on another cell but it won't allow me to be in edit mode.
I've tried following http://www.scottlogic.co.uk/blog/colin/2009/01/wpf-datagrid-committing-changes-cell-by-cell/ and http://codefluff.blogspot.com/2010/05/commiting-bound-cell-changes.html but neither appear to work on my case.
My Code for the CellEditEnding event
private void dgCompList_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
if (!isManualEditCommit)
{
isManualEditCommit = true;
System.Windows.Controls.DataGrid grid = (System.Windows.Controls.DataGrid)sender;
grid.CommitEdit(DataGridEditingUnit.Row, true);
isManualEditCommit = false;
}
}
I've also tried using CommitEdit() on the actual datagrid itself, but nada. Could someone explain to me what's going on and how to resolve this please?
normally, a red border around the cell is a error state, so it sounds like you have some type of validation error, to me.

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);
}

Resources