punker76 on develop
Update MessageDialog.cs Fix De… Merge pull request #4247 from c… (compare)
@seba30 Thx for the code. I can see that you use a FlipViewItem inside a FlipViewItem ;-) because the FlipViewItem is automatically generated by WPF itself, so you don't need to use a second one.
So my suggestion and maybe the easiest way is to use a Binding to the BannerText of the FlipView and the SelectedItem like
BannerText="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Title, FallbackValue={x:Null}}"
and then using this ItemTemplate
<mah:FlipView.ItemTemplate>
<DataTemplate DataType="interfaces:IPage">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<ContentControl Grid.Row="0" cm:View.Model="{Binding}" />
</Grid>
</DataTemplate>
</mah:FlipView.ItemTemplate>
Does anyone know if it's possible to change the underlying XAML definition of BaseMetroDialog
?
I have a custom style for dialog boxes, but I need to change the highlighted line below - since it's in BaseMetroDialog.xaml
, I'm not sure how to go about it:
System.InvalidOperationException: 'Context is not registered. Consider using DialogParticipation.Register in XAML to bind in the DataContext.'
_dialogCoordinator.HideMetroDialogAsync(Application.Current.MainWindow as MetroWindow, Dialog);
<mah:MetroWindow
mah:DialogParticipation.Register="{Binding}"
...
Powershell script :
$code = @"
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using System.IO;
using System.Reflection;
using System.Linq;
public class EmployeeInfo : IDataErrorInfo, INotifyPropertyChanged
{
private int _EmployeeID;
private string _Name;
private string _Title;
public event PropertyChangedEventHandler PropertyChanged;
public EmployeeInfo()
{
}
public int EmployeeID
{
get { return this._EmployeeID; }
set
{
this._EmployeeID = value;
this.RaisePropertyChanged("EmployeeID");
}
}
public string Name
{
get { return this._Name; }
set
{
this._Name = value;
this.RaisePropertyChanged("Name");
}
}
public string Title
{
get { return this._Title; }
set
{
this._Title = value;
this.RaisePropertyChanged("Title");
}
}
public string Error
{
get { return string.Empty; }
}
public string this[string columnName]
{
get
{
if (!columnName.Equals("Title"))
return string.Empty;
if (this.Title.Contains("Marketing"))
return "Marketing is not allowed";
return "string.Empty";
}
}
private void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
"@
Add-Type -TypeDefinition $code -Language CSharp
$TextboxTitle.DataContext = [PSCustomObject]@{
Title= "Marketing"
}
$Validation = [EmployeeInfo]::New()
$TextboxTitle.Add_TextChanged({
$Validation.Title = $SumRelease.Text
$Validation["Title"]
})
XAML File :
<TextBox x:Name="TextboxTitle" Grid.Row="0" Grid.Column="3" IsEnabled="True" Width="300" mah:TextBoxHelper.Watermark="Please enter the Release version." Text="{Binding Title, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" />