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>
Related
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>
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
I have ListView binding with my collection:
private List<MyData> Col;
ItemsSource="{Binding Col}"
I define this inside my ListView:
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Selected">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox x:Name="cbSelect" IsChecked="{Binding SupportedVendors}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding ID}" Header="ID" Width="600"/>
</GridView.Columns>
</GridView>
</ListView.View>
Now i want channge my object bool value inside my Collcection once the user change the CheckBox.
I can i do that ? (i need it in code behaind)
Tag the object of your collection with the CheckBox, the on check /uncheck you can get the tag from the checkbox checked. Change the bool value in the object.
why is this displaying date and time (rather than just date)?
<ListView Name="AttachmentsLB" Width="160" ItemsSource="{Binding Path=PicuAttachments}" >
<ListView.View>
<GridView>
<GridViewColumn Header="Start" DisplayMemberBinding="{Binding StartDate}" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=., StringFormat=d}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Finish" DisplayMemberBinding="{Binding FinishDate}" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=., StringFormat=d}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
I have also tried StringFormat = {}{0:d} and StringFormat = \{0:d\} with no success
problem of StringFormat on the wrong Binding
<GridViewColumn Header="Start" DisplayMemberBinding="{Binding StartDate, StringFormat=d}" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
How about using this? Change the StringFormat in your binding :
DisplayMemberBinding="{Binding Path=startDate, StringFormat='yyyy-MM-dd'}"
Hi there im using C# 3.5, this could be possible ?
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("date", "{dd/MM/YYYY}") %>'></asp:TextBox></EditItemTemplate>
<ItemTemplate>
I was trying :
<ListView Margin="0,80,0,38" Name="dlstInformes" Grid.ColumnSpan="2" >
<ListView.View>
<GridView>
<GridViewColumn Header="Numero Informe" DisplayMemberBinding="{Binding Path= numeroinforme}" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock >
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Nombre" DisplayMemberBinding="{Binding Path= nombreinforme}" />
<GridViewColumn Header="Fecha Informe" DisplayMemberBinding="{Binding Path= fechainforme}" />
</GridView>
</ListView.View>
one solution here:
<ListView Margin="0,80,0,38" Name="dlstInformes" MouseDoubleClick="dlstInformes_MouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn Header="Numero Informe" DisplayMemberBinding="{Binding Path= numeroinforme}" >
</GridViewColumn>
<GridViewColumn Header="Nombre" DisplayMemberBinding="{Binding Path= nombreinforme}" />
<GridViewColumn Header="Fecha Informe">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<Binding Path="fechainforme" StringFormat="{}{0:MM/dd/yyyy}"/>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
hopes helps...