![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Binding an ImageBrush Problem My XAML is the following: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="FontSize" Value="16" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid Name="buttonBackground" Background="{Binding Path=Background}"> <TextBlock Text="{Binding Path=Content}" /> <ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> This is my ButtonStyle. As you can see the grid background is bound to the Background property of the button, but hen i set it, the background remains empty What's the error? Thanks in advance for your help |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Binding an ImageBrush Problem Hello, use a {TemplateBinding Background} instead of {Binding ...} Kind regards, Henning Krause "star-italia" <star-italia@xxxxxx> wrote in message news:OL65a$uyIHA.552@xxxxxx Quote: > My XAML is the following: > > <ResourceDictionary > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> > <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> > <Setter Property="OverridesDefaultStyle" Value="True" /> > <Setter Property="SnapsToDevicePixels" Value="True" /> > <Setter Property="FontSize" Value="16" /> > <Setter Property="Template"> > <Setter.Value> > <ControlTemplate TargetType="{x:Type Button}"> > <Grid Name="buttonBackground" Background="{Binding Path=Background}"> > <TextBlock Text="{Binding Path=Content}" /> > <ContentPresenter Margin="2" HorizontalAlignment="Center" > VerticalAlignment="Center" RecognizesAccessKey="True"/> > </Grid> > </ControlTemplate> > </Setter.Value> > </Setter> > </Style> > </ResourceDictionary> > > This is my ButtonStyle. As you can see the grid background is bound to the > Background property of the button, but hen i set it, the background > remains > empty > > What's the error? > > Thanks in advance for your help |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Binding an ImageBrush Problem Thank you, it worked perfectly!!! But. exactly, what is the difference between Binding and TemplateBinding? Henning Krause [MVP - Exchange] wrote: Quote: > Hello, > > use a {TemplateBinding Background} instead of {Binding ...} > > Kind regards, > Henning Krause > > "star-italia" <star-italia@xxxxxx> wrote in message > news:OL65a$uyIHA.552@xxxxxx Quote: >> My XAML is the following: >> >> <ResourceDictionary >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> >> <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> >> <Setter Property="OverridesDefaultStyle" Value="True" /> >> <Setter Property="SnapsToDevicePixels" Value="True" /> >> <Setter Property="FontSize" Value="16" /> >> <Setter Property="Template"> >> <Setter.Value> >> <ControlTemplate TargetType="{x:Type Button}"> >> <Grid Name="buttonBackground" Background="{Binding Path=Background}"> >> <TextBlock Text="{Binding Path=Content}" /> >> <ContentPresenter Margin="2" HorizontalAlignment="Center" >> VerticalAlignment="Center" RecognizesAccessKey="True"/> >> </Grid> >> </ControlTemplate> >> </Setter.Value> >> </Setter> >> </Style> >> </ResourceDictionary> >> >> This is my ButtonStyle. As you can see the grid background is bound to >> the >> Background property of the button, but hen i set it, the background >> remains >> empty >> >> What's the error? >> >> Thanks in advance for your help |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Binding an ImageBrush Problem Hello, the relative source is different. {TemplateBinding Background} is equal to {Binding Background, RelativeSource={RelativeSource TemplatedParent}}. Google will certainly reveal more detailed explanations. Kind regards, Henning Krause "star-italia" <star-italia@xxxxxx> wrote in message news:%23hg0YgvyIHA.1240@xxxxxx Quote: > Thank you, it worked perfectly!!! > > But. exactly, what is the difference between Binding and TemplateBinding? > > Henning Krause [MVP - Exchange] wrote: Quote: >> Hello, >> >> use a {TemplateBinding Background} instead of {Binding ...} >> >> Kind regards, >> Henning Krause >> >> "star-italia" <star-italia@xxxxxx> wrote in message >> news:OL65a$uyIHA.552@xxxxxx Quote: >>> My XAML is the following: >>> >>> <ResourceDictionary >>> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >>> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> >>> <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> >>> <Setter Property="OverridesDefaultStyle" Value="True" /> >>> <Setter Property="SnapsToDevicePixels" Value="True" /> >>> <Setter Property="FontSize" Value="16" /> >>> <Setter Property="Template"> >>> <Setter.Value> >>> <ControlTemplate TargetType="{x:Type Button}"> >>> <Grid Name="buttonBackground" Background="{Binding Path=Background}"> >>> <TextBlock Text="{Binding Path=Content}" /> >>> <ContentPresenter Margin="2" HorizontalAlignment="Center" >>> VerticalAlignment="Center" RecognizesAccessKey="True"/> >>> </Grid> >>> </ControlTemplate> >>> </Setter.Value> >>> </Setter> >>> </Style> >>> </ResourceDictionary> >>> >>> This is my ButtonStyle. As you can see the grid background is bound to >>> the >>> Background property of the button, but hen i set it, the background >>> remains >>> empty >>> >>> What's the error? >>> >>> Thanks in advance for your help |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Binding an ImageBrush Problem Thanks Henning for your help! Hi Star-italia, A TemplateBinding is an optimized form of a Binding for template scenarios, analogous to a Binding constructed with {Binding RelativeSource={RelativeSource TemplatedParent}}. For more information on Binding and TemplateBinding, please refer to the following MSDN documents: "Binding Markup Extension" http://msdn.microsoft.com/en-us/library/ms750413.aspx "TemplateBinding Markup Extension" http://msdn.microsoft.com/en-us/library/ms742882.aspx Hope this helps. If you have any question, please feel free to let me know. Sincerely, Linda Liu Microsoft Online Community Support Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@xxxxxx. ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Binding an ImageBrush Problem Hi Star-italia, I am reviewing this post in the newsgroup and would like to know the status of this issue. If you have any question, please feel free to let me know. Thank you for using our MSDN Managed Newsgroup Support Service! Sincerely, Linda Liu Microsoft Online Community Support Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@xxxxxx. This posting is provided "AS IS" with no warranties, and confers no rights. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| wpf xml twoway data binding problem? | .NET General | |||
| Problem in dynamic WPF ListView binding | .NET General | |||