@Miosss in regards to the popup box that sort of makes sense, the VS designer has historically been a pain to work with. What version of Visual Studio are you on? I know some of the later version (16.8+) have had some significant rework and it may be worth taking another stab at addressing the design time of the controls.
For the second issue that sounds like a bug, do you mind opening an issue for it?
DynamicResource
to look up the style for the TextBox
. This subtlety gives you an injection point to insert your own style. As long as you base your style on the original one it lets you toggle stuff. Something like this:<DatePicker
Width="100"
materialDesign:HintAssist.Hint="Pick Date"
Style="{StaticResource MaterialDesignFloatingHintDatePicker}">
<DatePicker.Resources>
<Style x:Key="MaterialDesignDatePickerTextBox"
BasedOn="{StaticResource MaterialDesignDatePickerTextBox}"
TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Background" Value="Red" />
</Style>
</DatePicker.Resources>
</DatePicker>
-=
operator. You can see some examples and documentation here
Hi, I am trying to make a reusable "materialDesign:DialogHost" for a Yes / No confirmation Dialog. The only thing that would change on the control are the two texts inside two TextBlock. And I want to call it from the ViewModel and get the Yes / No result.
I followed the example called "DialogHost.WithResult" but it uses
<materialDesign:DialogHost.DialogContentTemplate>
<DataTemplate DataType="system:String">
<StackPanel Margin="20">
<TextBlock Text="{Binding}" />
</StackPanel>
</DataTemplate>
</materialDesign:DialogHost.DialogContentTemplate>
wich allow to pass only one string from the ViewModel.
So is it possible instead to make a reussable DialogHost and instead of setting the DialogContentTemplate with a string we pass two strings directly to DialogContent ?
@AmraniRiyad Hi! You can create your own user control. For example
Code-behind:
var myUserControl = new MyUserControl("myFirstString", "mySecondString");
var result = await MaterialDesignThemes.Wpf.DialogHost.Show(myUserControl);
Custom user control's textblocks should binds to those strings.
<TextBlock Text="{Binding Text1, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MyUserControl}}"/>
<TextBlock Text="{Binding Text2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MyUserControl}}"/>
In MyUserControl view (xaml.cs):
public string Text1 { get; }
public string Text2 { get; }
In main window just remove data content template.
<DataTemplate DataType="{x:Type toolsViewModels:ConfirmationDialogHostViewModel}">
<controls:ConfirmationDialogHost HeaderText="{Binding HeaderText}" Text="{Binding Text}" />
</DataTemplate>