yotabit
yotabit
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
Yes. I didn't find that either. But the codebehind solution or their visibility works as well, so I'll use that. Thank you again!
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
I would prefer to not set every property, but just use the style that is ready
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
Here's the code that changes the background:
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CancellationVisible}" Value="False">
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CancellationVisible}" Value="False">
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
Thank you for you comment! The problem is: the Accent Button is not just the Default button with a different background(Accent). When {StaticResource MahApps.Styles.Button.Dialogs.Accent} style is applied, it also changed properties like the Foreground to white, on mouse over, etc
15 replies
CC#
Created by LDami on 9/17/2022 in #help
Is there any benefit to write a Property with a private variable ?
Yes. It's exactly the same value
34 replies
CC#
Created by LDami on 9/17/2022 in #help
Is there any benefit to write a Property with a private variable ?
I think that the easiest way to see the reason is to understand that not always you'll just get/set the same value. For example:
private int myVar;
public string MyVar
{
get => myVar.toString();
set => myVar;
}
private int myVar;
public string MyVar
{
get => myVar.toString();
set => myVar;
}
In this case, you return a String, but what you have is an integer
34 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
As far as I understood from it, that's indeed not the answer. I'm still looking for how I can do it. Do you have more suggestions?
15 replies
CC#
Created by yotabit on 9/17/2022 in #help
Style dependent on a property
I first tried something similar to what is written there, but it gives an error that I can't use a Style to change its Style
<Button x:Name="ConfirmationButton">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CancellationVisible}" Value="False">
<Setter Property="Style" Value="{StaticResource MahApps.Styles.Button.Dialogs.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button x:Name="ConfirmationButton">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CancellationVisible}" Value="False">
<Setter Property="Style" Value="{StaticResource MahApps.Styles.Button.Dialogs.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Any ideas how I could fix it?
15 replies
CC#
Created by yotabit on 9/1/2022 in #help
Color brush from App.xaml
Yes. That works. Thank you! I tried something similar, but I see my problem was that I didn't know that I could access the App as Application.Current
3 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
Is there a better way to do it? Should I leave these Resources somewhere else?
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
So, I need to find their path. I found a way to get my source code path, then I added /Resources and that's it. Now I can access them
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
I have a folder called Resources. Inside, I have images and audios. I'd like to open one of them as I need
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
I'm wondering if there isn't a straightforward solution and if it's indeed a good idea to do like this
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
Given what Retax wrote, I found that it's possible to do without the split function
private static string path = GetThisFilePath();
private readonly string directory = Path.GetDirectoryName(path);
private static string path = GetThisFilePath();
private readonly string directory = Path.GetDirectoryName(path);
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
Thank you for the help!
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
No. I'm not
12 replies
CC#
Created by yotabit on 8/25/2022 in #help
Project Path
Got it
12 replies