Adding a user control to a GridViewColumn - wpf

I'm trying to add a custom user control of mine to a GridViewColumn and all I get is the ToString() output of that control.
my code:
<GridViewColumn Header="Progress" HeaderContainerStyle="{StaticResource MyHeaderStyle}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding ProgressBar, Converter={StaticResource nullGuestImageConverter}}" Width="150" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
I have tried before
<GridViewColumn HeaderContainerStyle="{StaticResource MyHeaderStyle}" Header="Status" DisplayMemberBinding="{Binding ProgressBar}" />
to no avail.
please help

Related

How to bind double click on row to command in GridView that inside ListView in MVVM WPF

I'm prrety new to wpf, and i try to make a GridView that inside ListView to response to double click on row in the view
I try to make this-
<ListView
ItemsSource="{Binding Products}">
<ListView.InputBindings>
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding Test}" />
</ListView.InputBindings>
<ListView.View>
<GridView>
</GridView.ColumnHeaderContainerStyle>
<GridViewColumn
Header="ID"
DisplayMemberBinding="{Binding ID}" />
<GridViewColumn
Header="Name"
DisplayMemberBinding="{Binding Name}" />
<GridViewColumn
Header="Category"
DisplayMemberBinding="{Binding Category}" />
<GridViewColumn
Header="Price"
DisplayMemberBinding="{Binding Price}" />
</GridView>
</ListView.View>
<ListView />
when Test is an ICommand property in the view model.
But it's not responding to double click.
What am I getting wrong, and mabye there is another way?

WPF ListView Column width

I used list view with a single column, I would like this column with the same size list view with.
I mean Just one column fill the all with of the list view.
I tried this but didn't work...
<ListView Grid.Row="1" Grid.Column="1" x:Name="LvErrorList">
<ListView.View>
<GridView>
<GridViewColumn Width="{Binding ActualWidth, ElementName=LvErrorList}" Header="Status" DisplayMemberBinding="{Binding ErrorMessage}" />
</GridView>
</ListView.View>
</ListView>
I tried
<GridViewColumn Width="Auto" Header="Status" DisplayMemberBinding="{Binding ErrorMessage}" />
But some text are longer than the with of the ListView.
Becaues i don't know the user screen size i can't set max-width property.
Does anyone know how to fix this please?
You can try this way instead.
<ListView Grid.Row="1" Grid.Column="1" x:Name="LvErrorList">
<ListView.View>
<GridView>
<GridViewColumn Header="Status" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorMessage}" Width="{Binding ElementName=LvErrorList,Path=ActualWidth}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

WPF how to change text color of a GridViewColumn?

I have this GridViewColumn:
<GridViewColumn Width="180" Header="Status" DisplayMemberBinding="{Binding Status}"/>
Now i want to be able to change this Column text color also via code behind.
I try:
<GridViewColumn Width="180" Header="Status" DisplayMemberBinding="{Binding Status}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="Txt" Text="{Binding Status}" Foreground="Yellow" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
But it seems that the text color is not changing.
Since you already specifying the celltemplate for each item, you don't need to include the DisplayMemberBinding property, just remove it
<GridViewColumn Width="180" Header="Status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock x:Name="Txt" Text="{Binding Status}" Foreground="Yellow" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

WPF GridView in ListView with CheckBox in header error

I have problems to add a checkbox in the grid view header. When I add it appears like a ToString() of the checkbox.
My XAML is this:
<ListView x:Name="grdLotes" BorderThickness="0" Margin="0,0,20,0" >
<ListView.View>
<GridView AllowsColumnReorder="False" ColumnHeaderToolTip="Lotes">
<GridViewColumn Width="70">
<CheckBox></CheckBox>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="NĂºmero" Width="70"/>
<GridViewColumn Header="Tipo" Width="Auto"/>
<GridViewColumn Header="Comentario" Width="Auto"/>
<GridViewColumn Header="Movimientos" Width="80"/>
</GridView>
</ListView.View>
</ListView>
This is what shows:
Any idea how to solve this?
I tried to add into <GridViewColumn.Header> but is the same

Checkbox is not displaying in rows from ListView

I created list view with check box at column 1, but it's displaying only at header level and in rows i'm getting namespace name.
Here's the XAML code:
<ListView x:Name="ConfigurationFilesGrid" ItemsSource="{Binding ConfigurationFiles}"
SelectedItem="{Binding SelectedProgramFile}"
ScrollViewer.CanContentScroll="True"
PreviewMouseDoubleClick="ConfigurationFilesGrid_Reselect"
>
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.HeaderTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding ElementName=ConfigurationMainCtrl, Path=DataContext.IsAllConfigurationSelected}"/>
</DataTemplate>
</GridViewColumn.HeaderTemplate>
</GridViewColumn>
<GridViewColumn Header="{x:Static res:Resources.IDColNameTxt}" DisplayMemberBinding="{Binding ID}" />
<GridViewColumn Header="{x:Static res:Resources.TypeColHdr}" DisplayMemberBinding="{Binding DisplayType}" />
<GridViewColumn Header="{x:Static res:Resources.NameColNameTxt}" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="{x:Static res:Resources.MeterColNameTxt}" DisplayMemberBinding="{Binding MeterType}"/>
<GridViewColumn Header="{x:Static res:Resources.RateColNameTxt}" DisplayMemberBinding="{Binding RateDisplay}"/>
<GridViewColumn Header="{x:Static res:Resources.CommentColNameTxt}" DisplayMemberBinding="{Binding Comment}"/>
<GridViewColumn Header="{x:Static res:Resources.ModifiedDateColNameTxt}" DisplayMemberBinding="{Binding ModifiedDateTime}"/>
<GridViewColumn Header="{x:Static res:Resources.ProfileColNameTxt}" DisplayMemberBinding="{Binding Profile}"/>
</GridView>
</ListView.View>
</ListView>
And i'm getting list view like:
[](checkbox) ID Name Address
name 1 A X
name 2 B Y
But from above i'm getting checkbox only at header level not rows level so what change 'll reflect to checkbox from above xaml code.
Thanks for you help.
Nag
You've used the HeaderTemplate of the GridViewColumn, use the CellTemplate instead:
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding ElementName=ConfigurationMainCtrl, Path=DataContext.IsAllConfigurationSelected}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

Resources