I need to change border style to invisible on "DataGridComboBoxColumn"...
How can I do it? I hope there is another way then changing to datagridTemplate and put combobox element with my style inside....
You can try this solution:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a5777acb-ef85-40e3-b371-d803cbe26763/
I needed to add .EditingElementStyle
<wpfToolkit:DataGridComboBoxColumn x:Name="dgcSource" Header="Source"
SelectedValueBinding="{Binding ObjectItemSourceId, TargetNullValue=0}"
SelectedValuePath="ID"
DisplayMemberPath="Name"
SortMemberPath="SourceName">
<wpfToolkit:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="BorderBrush" Value="Transparent"/>
</Style>
</wpfToolkit:DataGridComboBoxColumn.EditingElementStyle>
</wpfToolkit:DataGridComboBoxColumn>
Related
I have extended ListBox control and wanted to give it rounded corner so I have applied styles as below and it works fine:
<control:MultiSelectionListBox SelectionMode="Extended" ItemsSource="{Binding Offerables,Mode=TwoWay}"
SelectedItemsList="{Binding SelectedOfferables, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="Name"
Grid.Row="6" Grid.Column="0" MaxHeight="150">
<control:MultiSelectionListBox.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"></Setter>
</Style>
</control:MultiSelectionListBox.Resources>
</control:MultiSelectionListBox>
but I have too many Listboxes and I don't wanted to add style in each and every control individually.
I wanted to define this style in app.xaml and wanted to reuse that design by name like Style = "{StaticResource RoundedListBoxStyle}".
I have tried like below in app.xaml but with no luck
<Style TargetType="ListBox" x:Key="RoundedListBoxStyle">
<Setter Property="Border" Value="10"></Setter>
</Style>
The member Border is not recognized or is not accessible.
Please guide me what I am doing wrong here.
Finally I managed to do that as Bradley Uffner mentioned in the comment Border is not the property of the ListBox and we cannot use it in style like that. I used Style.Resource and mentioned Style for Border elements as below:
<Style TargetType="ListBox" x:Key="RoundedListBoxStyle">
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"></Setter>
</Style>
</Style.Resources>
</Style>
and it worked. :)
I have a treeview that need to refresh due to data changes. Is it
possible to refresh and select the last node that they were viewing when the tree view was been populated once again?
Thanks for any help.
For auto refresh you can create some ViewModel for treeView. Something like in my answer Binding a WPF TreeView to multiple Lists . To update selected item and expand it you should define in ViewModel IsSelected and IsExpanded properties (like Name property, but bool). And you should define ItemContainerStyle in your TreeView like this.
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</TreeView.ItemContainerStyle>
When I try to display alternate colors in my datagrid rows,
both RowBackground and AlternatingRowBackground works when used inside Datagrid tag like this :
<DataGrid Name="datagrid"
RowBackground="CadetBlue"
AlternatingRowBackground="LightBlue">
But when i used this properties inside Style tag like this ,
<Style TargetType="{x:Type DataGrid}">
<Setter Property="RowBackground" Value="CadetBlue" />
<Setter Property="AlternatingRowBackground" Value="LightBlue" />
</Style>
It doesnt work.
Can someone tell me the reason behind this.
Thank you in advance.
Unless I add DisplayMemberPath on the combobox it does not work. I think it should take it from Style?
I have the comboBox initially disabled. I see it can work when I open another tab with same DataTemplate. Once it works on one instance, it imdly starts working on all. Is is anything to do with tabs?
<Style x:Key="CollectionList" TargetType="ComboBox">
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="IsEditable" Value="True"/>
<Setter Property="IsSynchronizedWithCurrentItem" Value="False"/>
<Setter Property="DisplayMemberPath" Value="Name"/>
</Style>
<ComboBox ItemsSource="{Binding Items}"
Style="{StaticResource CollectionList}"
SelectedItem="{Binding Model.SelectedItem}" />
Change your Style="{StaticResource CollectionList}" to a DynamicResource
I am guessing it has something to do with the StaticResource getting loaded once, and the TabControl items getting loaded as needed
How to make DataGrid transparent?
I'm trying to use Background of DataGrid itself, but this doesn't seem to work.
UPD I need only background and borders transparent, not everything! Text should be visible.
So, my solution... use both Background="Transparent" and RowBackground="Transparent"
Have you tried setting the Opacity property to 0.0 ?
A value of 0.0 makes the element
completely transparent
<DataGrid
Background="Transparent" RowBackground="Transparent">
</DataGrid>
Try this:
Background="Transparent" RowBackground="Transparent"
and
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="Transparent" />
</Style>
</DataGrid.RowHeaderStyle>
It's an undocumentd feature but if you set the visability to Hidden it's the same as setting the element to transparent.
I'm not sure which background you are trying to change, but you can set any background by overriding the DataGrid's ControlTemplate. Your best bet is probably to copy the default DataGrid ControlTemplate from here and then modify the necessary background to match your needs.
When you inicialize datagrid put this tag GridLinesVisibility with argument None
For example:
<DataGrid GridLinesVisibility="None"/>