Click here to Skip to main content
15,914,500 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Binding problem Pin
Pete O'Hanlon17-May-11 1:01
mvePete O'Hanlon17-May-11 1:01 
GeneralRe: Binding problem Pin
Tarun.K.S17-May-11 2:21
Tarun.K.S17-May-11 2:21 
AnswerRe: Binding problem Pin
Abhinav S17-May-11 0:12
Abhinav S17-May-11 0:12 
GeneralRe: Binding problem Pin
Pete O'Hanlon17-May-11 0:53
mvePete O'Hanlon17-May-11 0:53 
GeneralRe: Binding problem Pin
Abhinav S17-May-11 18:23
Abhinav S17-May-11 18:23 
GeneralRe: Binding problem Pin
Pete O'Hanlon17-May-11 20:28
mvePete O'Hanlon17-May-11 20:28 
AnswerRe: Binding problem Pin
yesotaso23-May-11 22:31
yesotaso23-May-11 22:31 
QuestionThread Issue: "Import" DrawingGroup Pin
Paul Selormey16-May-11 14:47
Paul Selormey16-May-11 14:47 
AnswerRe: Thread Issue: "Import" DrawingGroup Pin
Mark Salsbery16-May-11 15:44
Mark Salsbery16-May-11 15:44 
GeneralRe: Thread Issue: "Import" DrawingGroup Pin
Paul Selormey16-May-11 15:53
Paul Selormey16-May-11 15:53 
GeneralRe: Thread Issue: "Import" DrawingGroup Pin
Paul Selormey17-May-11 1:02
Paul Selormey17-May-11 1:02 
QuestionHow to modify DataTemplate programmatically? Pin
Tesic Goran16-May-11 1:24
professionalTesic Goran16-May-11 1:24 
AnswerRe: How to modify DataTemplate programmatically? Pin
Abhinav S16-May-11 2:04
Abhinav S16-May-11 2:04 
GeneralRe: How to modify DataTemplate programmatically? Pin
Tesic Goran16-May-11 2:35
professionalTesic Goran16-May-11 2:35 
AnswerRe: How to modify DataTemplate programmatically? Pin
Abhinav S16-May-11 3:10
Abhinav S16-May-11 3:10 
AnswerRe: How to modify DataTemplate programmatically? Pin
Mark Salsbery16-May-11 2:44
Mark Salsbery16-May-11 2:44 
GeneralRe: How to modify DataTemplate programmatically? Pin
Tesic Goran16-May-11 3:00
professionalTesic Goran16-May-11 3:00 
GeneralRe: How to modify DataTemplate programmatically? Pin
Mark Salsbery16-May-11 3:04
Mark Salsbery16-May-11 3:04 
AnswerRe: How to modify DataTemplate programmatically? Pin
SledgeHammer0116-May-11 6:21
SledgeHammer0116-May-11 6:21 
GeneralRe: How to modify DataTemplate programmatically? Pin
Tesic Goran17-May-11 1:24
professionalTesic Goran17-May-11 1:24 
GeneralRe: How to modify DataTemplate programmatically? Pin
Pete O'Hanlon17-May-11 1:54
mvePete O'Hanlon17-May-11 1:54 
Indeed, and for those who are interested, here's an example of a template that can be applied to a checkbox. Basically, this DataTemplate uses a trigger to change a control template when the IsSelected value changes. Just for clarity - this isn't the best way to restyle a checkbox, it just demonstrates using a DataTemplate and ControlTemplate elements. BTW - this is a purely XAML based alternative to a DataTemplateSelector.
XML
<ControlTemplate x:Key="OnTemplate">
 <Grid ToolTip="{Binding Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}">
  <Rectangle HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center" Width="80" Height="20" RadiusX="3" RadiusY="3">
   <Rectangle.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FF6183DC" Offset="0"/>
     <GradientStop Color="#FFC6CDE0" Offset="1"/>
    </LinearGradientBrush>
   </Rectangle.Fill>
  </Rectangle>
  <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="ON" TextWrapping="Wrap" Margin="8,0,0,0" FontSize="16" FontWeight="Bold" Foreground="#FFFEFCFC"/>
  <Rectangle RadiusX="3" RadiusY="3" HorizontalAlignment="Left" Margin="40,0,0,0" VerticalAlignment="Center" Width="40" Height="20">
   <Rectangle.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FFB5B1B1" Offset="0.004"/>
     <GradientStop Color="White" Offset="1"/>
    </LinearGradientBrush>
   </Rectangle.Fill>
  </Rectangle>
 </Grid>
</ControlTemplate>
<ControlTemplate x:Key="OffTemplate">
 <Grid ToolTip="{Binding Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}">
  <Rectangle HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center" Width="80" Height="20" RadiusX="3" RadiusY="3">
   <Rectangle.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FFE0E7F8" Offset="0"/>
     <GradientStop Color="#FFF2F4FA" Offset="1"/>
    </LinearGradientBrush>
   </Rectangle.Fill>
  </Rectangle>
  <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="OFF" TextWrapping="Wrap" Margin="44,0,0,0" FontSize="16" FontWeight="Bold" Foreground="#FFB3ABAB"/>
  <Rectangle RadiusX="3" RadiusY="3" HorizontalAlignment="Left" Margin="1,0,0,0" VerticalAlignment="Center" Width="40" Height="20">
   <Rectangle.Fill>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FFB5B1B1" Offset="0.004"/>
     <GradientStop Color="White" Offset="1"/>
    </LinearGradientBrush>
   </Rectangle.Fill>
  </Rectangle>
 </Grid>
</ControlTemplate>

<DataTemplate x:Key="toggleTemplate">
 <Control x:Name="toggleControl" Template="{StaticResource OnTemplate}" />
 <DataTemplate.Triggers>
  <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type CheckBox}}}" Value="False">
   <Setter Property="Template" TargetName="toggleControl" Value="{StaticResource OffTemplate}" />
  </DataTrigger>
 </DataTemplate.Triggers>
</DataTemplate>

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


Questionobjects added to an IDictionary must have a Key attribute [modified] Pin
Lutosław15-May-11 23:20
Lutosław15-May-11 23:20 
NewsRe: objects added to an IDictionary must have a Key attribute Pin
Lutosław16-May-11 0:05
Lutosław16-May-11 0:05 
AnswerRe: objects added to an IDictionary must have a Key attribute Pin
Venkatesh Mookkan16-May-11 0:41
Venkatesh Mookkan16-May-11 0:41 
AnswerRe: objects added to an IDictionary must have a Key attribute Pin
markovl16-May-11 0:53
markovl16-May-11 0:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.