Я пытаюсь заполнить кнопку дорожкой и получить аргумент за пределами исключения. Я привязываюсь в своем представлении к собственности на модели. Код для собственности:Аргумент за пределами допустимого диапазона Геометрия windows phone 8.1
public PunishmentName Name { get; set; }
public Geometry IconData
{
get
{
string data = "";
switch (Name)
{
case PunishmentName.Freeze:
data = "M 0 0 Q 10 10 20 0";
break;
}
Path path = XamlReader.Load("<Path " + "xmlns=" + "'" + "http://schemas.microsoft.com/winfx/2006/xaml/presentation" + "'" + " Data= '" + data + " '/>") as Path;
Geometry geometry = path.Data;
return geometry;
}
}
код для кнопки в окне
<Button Grid.Row="1" BorderBrush="Transparent" >
<Viewbox>
<Path Data="{Binding Punishment.IconData}"/>
</Viewbox>
</Button>
Я знаю, этот вопрос: уже был задан здесь: Windows Phone 7: How to parse Bezier Path string like in XAML?
Я попытался положив Путь в сетку и холст также с тем же результатом.
Но он не решается там ... И я здесь новый, поэтому я не могу комментировать и не чувствую себя комфортно, задавая вопрос как ответ. Я тут застрял. Я могу думать о работе вокруг, но это означало бы намного больше работы и уродливый код ...
Исключение:
{System.Windows.ApplicationUnhandledExceptionEventArgs}
base: {System.Windows.ApplicationUnhandledExceptionEventArgs}
ExceptionObject: {System.ArgumentException: Value does not fall within the expected range.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)}
Handled: false
Я сделал точно так же в приложении WPF с Geometry.Parse но это все еще не доступно для телефона ...
Существует встроенный конвертер - вам не нужно, чтобы IconData был * Геометрия * - сделайте это 'public string IconData' и в getter' return data' (например data = "M 0 0 Q 10 10 20 0") - она также должна работать. – Romasz
Это правда? http://stackoverflow.com/questions/22119053/system-exception-system-argumentexception-value-does-not-fall-within-the-expec – dbc
спасибо dbc и всем, Romasz дал решение. –