Click here to Skip to main content
15,918,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,

I have a datagrid looks like this below

VB
<sdk:DataGrid AutoGenerateColumns="False" Height="Auto" MaxHeight="500"
                        HorizontalAlignment="Left" Margin="5" Name="_EmployeeGrid"
                        ItemsSource="{Binding Path= Employees,Mode=TwoWay}"
                        HorizontalScrollBarVisibility="Auto"
                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                        Visibility="Visible"
                        VerticalAlignment="Top" Width="Auto">


XML
<sdk:DataGridTemplateColumn x:Name="Notes1" Header="Notes">
                                            <sdk:DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal" >
                                                        <TextBlock  MaxWidth="200"  TextAlignment="Left" TextWrapping= "Wrap" Text="{Binding Path=Comments, Mode=OneWay}" Width="200" />
                                                        <HyperlinkButton Name="btnEllipsis" Visibility="{Binding EllipsisVisibility,Source={StaticResource ViewModel}}" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="15" Content="..."  ToolTipService.ToolTip="Click For More" Command="{Binding NotesCommand,Source={StaticResource ViewModel}}" CommandParameter="{Binding}" >
                                                        </HyperlinkButton>


                                                    </StackPanel>
                                                </DataTemplate>
                                            </sdk:DataGridTemplateColumn.CellTemplate>
                                        </sdk:DataGridTemplateColumn>


                                </sdk:DataGrid>





and I am setting the visibility property in view model as below

string _ellipsisVisibility;

public string EllipsisVisibility
{
get { return _ellipsisVisibility; }
set
{
if (_ellipsisVisibility != value)
{
_ellipsisVisibility = value;
RaisePropertyChanged("EllipsisVisibility");

}
}
}

setting
EllipsisVisibility="Collapsed";
and
EllipsisVisibility="Visible";



The problem is its not working. I have basically two requirements one is to simply hide and show it. Secondly based on some condition few rows will have it and few won't like RowDataBound like event in silverlight with mvvm. Can anyone please help?
Posted
Updated 12-Jul-14 8:05am
v2
Comments
[no name] 12-Jul-14 15:05pm    
Well your first problem is, is that the Visibility property is not a string.

1 solution

Hi Somnath,

Try the below things:

1. Raise the property change notification inside the Dispatcher.BeginInvoke() like this:
Dispatcher.BeginInvoke(() => RaisePropertyChanged("EllipsisVisibility"));

2. If the above does not work, try the below binding expression:
<hyperlinkbutton name="btnEllipsis" visibility="{Binding EllipsisVisibility,Source={StaticResource ViewModel}, UpdateSourceTrigger=PropertyChanged}" ...="">

UPDATE:
I just noticed that, you have created the Visibility property as String. This should never be the ideal case. Please change the property type to Visibility instead of String. I hope, this change will work for you. If sont, then follow the above steps.

Let me know, what happens next.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900