TechTalkz.com Logo Ask the Expert

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Expression

Notices

DataTemplate, Triggers, and Binding

Microsoft Expression


Reply
 
Thread Tools Display Modes
Old 21-02-2008, 09:17 PM   #1
sryan
Guest
 
Posts: n/a
DataTemplate, Triggers, and Binding

I have a gridview which uses two datatemplates. One shows a check that tells
me if a user has a password and the other is a button that is supposed to
clear that password out of the database. When the application first runs,
everything looks great. Users that have passwords have a check next to them,
those that don't have nothing. When I click my Clear Password Button the
password gets deleted from the database (after hitting save of course). My
problem is that my UI doesn't refresh.

When I click my Clear Password button I would expect my datatemplate for my
check to se that there's not a password any more (because it's bound)
andtherefore get rid of the check. However, the check stays onscreen. The
check doesn't go away until the entire area is saved. I want it to happen
immediately. I'm currently using binding , UpdateSourceTrigger and
NotifyPropertyChanged. What else could I be missing?

These are my datatemplates:
<DataTemplate x:Key="PasswordCell">
<Canvas Visibility="Visible" Margin="2,-2,-2,2" x:Name="canvas">
<Path Fill="{x:Null}" Stretch="Fill" Stroke="{DynamicResource BrushDark}"
StrokeThickness="2" Width="10" Height="15" Data="M0,13 L12.835282,1.4144527"
Canvas.Left="4" Canvas.Top="-2" />
<Path Fill="{x:Null}" Stretch="Fill" Stroke="{DynamicResource BrushDark}"
StrokeThickness="2" Width="7" Height="7" Data="M0,0.36238045 L11.151966,13"
Canvas.Top="5.79" />
</Canvas>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=ProfileSectionPassword,
UpdateSourceTrigger=PropertyChanged}" Value="">
<Setter Property="Visibility" TargetName="canvas" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>

<DataTemplate x:Key="PasswordClearCell">
<Button IsEnabled="{Binding Path=EnablePasswordClear}"
Click="OnClearSectionPassword" Content="Clear Password" />
</DataTemplate>

Here's the Properties they're Binding to:
private Visibility sectionHasPassword;
public Visibility SectionHasPassword
{
get { return sectionHasPassword; }
set { sectionHasPassword = value;
NotifyPropertyChanged("SectionHasPassword"); }
}
private string profileSectionPassword = "";
public string ProfileSectionPassword
{
get {if (profileSectionPassword == null) profileSectionPassword
= "";
return profileSectionPassword;
}
set { profileSectionPassword = value;
NotifyPropertyChanged("ProfileSectionPassword"); }
}

Here's the rest of the code:
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}

private void OnClearSectionPassword(object sender, RoutedEventArgs e)
{
Button temp = (Button)sender;

((ProfileExpanderLineItem)(((ContentPresenter)(tem p.TemplatedParent)).Content)).ProfileSectionPasswo rd = "";
}

Anybody have any ideas? I'd appreciate it.
  Reply With Quote
Reply

Thread Tools
Display Modes



< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT +5.5. The time now is 10:12 PM.


vBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2010, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional