Click here to Skip to main content
15,881,938 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
Oscar Tsai13-Oct-21 15:14
Oscar Tsai13-Oct-21 15:14 
GeneralRe: [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM) Pin
michaelbarb14-Oct-21 12:38
michaelbarb14-Oct-21 12:38 
QuestionProblem Setting Focus Pin
Kevin Marois24-May-21 9:39
professionalKevin Marois24-May-21 9:39 
AnswerRe: Problem Setting Focus Pin
Richard Deeming24-May-21 21:56
mveRichard Deeming24-May-21 21:56 
QuestionImpossible to override a value in an animation located in a style? Pin
Mc_Topaz20-May-21 6:51
Mc_Topaz20-May-21 6:51 
AnswerRe: Impossible to override a value in an animation located in a style? Pin
Gerry Schmitz20-May-21 8:08
mveGerry Schmitz20-May-21 8:08 
QuestionApp Security Behavior Pin
Kevin Marois20-May-21 6:09
professionalKevin Marois20-May-21 6:09 
QuestionOverride a value in base style's resource Pin
Mc_Topaz20-May-21 2:45
Mc_Topaz20-May-21 2:45 
I have two style FooStyle and BarStyle.
I also have three TextBlocks and two of them use the styles above.

In the FooStyle I have specified a double (the Wid parameter) that is used to set the Width of the TextBlock (txt2) to 20.
In the BarStyle I would like to use the FooStyle but override the Wid parameter with the value 40 on the TextBlock (txt3).

But the txt3 TextBlock's Width don't get a longer Width. It still has the same Width as txt2.

Here is my code
XML
<Window x:Class="Main.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <Window.Resources>
        <Style x:Key="FooStyle" TargetType="TextBlock">
            <Style.Resources>
                <sys:Double x:Key="Wid">20</sys:Double>
            </Style.Resources>
            <Setter Property="Width" Value="{StaticResource Wid}" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>
        <Style x:Key="BarStyle" TargetType="TextBlock" BasedOn="{StaticResource FooStyle}">
            <Style.Resources>
                <sys:Double x:Key="Wid">40</sys:Double>
            </Style.Resources>
        </Style>
    </Window.Resources>

    <StackPanel Orientation="Vertical">
        <TextBlock Text="txt1" Background="red" Width="100" />
        <TextBlock Text="txt2" Background="Lime" Style="{StaticResource FooStyle}" />
        <TextBlock Text="txt3" Background="Blue" Style="{StaticResource BarStyle}" />
    </StackPanel>
</Window>
Is it possible to overwrite the Wid parameter in the BarStyle?
AnswerRe: Override a value in base style's resource Pin
Richard Deeming20-May-21 4:33
mveRichard Deeming20-May-21 4:33 
GeneralRe: Override a value in base style's resource Pin
Mc_Topaz20-May-21 6:00
Mc_Topaz20-May-21 6:00 
QuestionApply TextBlock Captions at Runtime Pin
Kevin Marois14-May-21 9:34
professionalKevin Marois14-May-21 9:34 
AnswerRe: Apply TextBlock Captions at Runtime Pin
Peter_in_278014-May-21 13:36
professionalPeter_in_278014-May-21 13:36 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Kevin Marois14-May-21 13:42
professionalKevin Marois14-May-21 13:42 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Pete O'Hanlon14-May-21 23:51
mvePete O'Hanlon14-May-21 23:51 
AnswerRe: Apply TextBlock Captions at Runtime Pin
Mycroft Holmes15-May-21 12:25
professionalMycroft Holmes15-May-21 12:25 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Gerry Schmitz16-May-21 11:17
mveGerry Schmitz16-May-21 11:17 
QuestionWPF TextBox Handle Data Pasted In Pin
Kevin Marois14-Apr-21 8:29
professionalKevin Marois14-Apr-21 8:29 
AnswerRe: WPF TextBox Handle Data Pasted In Pin
Richard Deeming14-Apr-21 22:50
mveRichard Deeming14-Apr-21 22:50 
GeneralRe: WPF TextBox Handle Data Pasted In Pin
Kevin Marois15-Apr-21 5:49
professionalKevin Marois15-Apr-21 5:49 
QuestionFormat Percentage Pin
Kevin Marois13-Apr-21 9:16
professionalKevin Marois13-Apr-21 9:16 
AnswerRe: Format Percentage Pin
Richard Deeming13-Apr-21 22:36
mveRichard Deeming13-Apr-21 22:36 
GeneralRe: Format Percentage Pin
Kevin Marois14-Apr-21 7:42
professionalKevin Marois14-Apr-21 7:42 
QuestionAvalonEdit Sytax Highlighting for XAML files? Pin
#realJSOP5-Apr-21 8:57
mve#realJSOP5-Apr-21 8:57 
AnswerRe: AvalonEdit Sytax Highlighting for XAML files? Pin
Richard Deeming6-Apr-21 0:22
mveRichard Deeming6-Apr-21 0:22 
QuestionRevert Property Change Pin
Kevin Marois5-Apr-21 7:20
professionalKevin Marois5-Apr-21 7:20 

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.